当前位置:网站首页>C语言 素数对猜想
C语言 素数对猜想
2022-06-30 01:25:00 【Martin の Blog】

算法设计思路
- 获取素数(注意,该部分课程产生运行超时,使用sqrt可以解决)
- 判断素数是否相邻
- 打印结果
代码
#include <stdio.h>
#include <math.h>
int issushu(int x){
int count = 0;
for(int i=2; i<sqrt(x)+1; i++){
if(x % i==0){
return 0;
}
}
return 1;
}
int main(){
int n, i;
int x=0;
scanf("%d", &n);
for(i=5; i<=n; i++){
if(issushu(i-2) && issushu(i)){
x++;
}
}
printf("%d", x);
return 0;
}
运行结果
边栏推荐
- R语言线性回归模型拟合诊断异常值分析家庭燃气消耗量和卡路里实例带自测题
- 田口实验法
- MySQL function
- How to refuse the useless final review? Ape tutoring: it is important to find a suitable review method
- postman 之接口关联
- 3-6sql injection website instance step 5: break through the background to obtain web administrator permissions
- Interview summary
- Interface Association of postman
- Questions about database: database attachment
- 【图神经网络】图分类学习研究综述[3]:图分类方法评价及未来研究方向
猜你喜欢

Sentinel source code analysis Part 7 - sentinel adapter module - Summary

ResizeKit2.NET大小和分辨率独立

Kubernetes core object overview details

Online text digit recognition list summation tool

Clean, talk, bring children, and get rid of the label of "artificial mental retardation" for the sweeper

【机器学习Q&A】余弦相似度、余弦距离、欧式距离以及机器学习中距离的含义

Online sql to CSV tool

Three text to speech artifacts, each of which is very practical

The first technology podcast month will be launched soon

R language linear regression model fitting diagnosis outliers analysis of domestic gas consumption and calorie examples with self-test questions
随机推荐
Online text digit recognition list summation tool
Can mango hypermedia, which "braves the wind and waves", go ashore?
【图神经网络】图分类学习研究综述[2]:基于图神经网络的图分类
【机器学习Q&A】数据抽样和模型验证方法、超参数调优以及过拟合和欠拟合问题
Pytroch Learning Notes 6: NN network layer convolution layer
Sentinel source code analysis Part 6 - sentinel adapter module Chapter 4 zuul2 gateway
The 8th "Internet +" competition - cloud native track invites you to challenge
Embedded exit (review and release)
[Thesis Writing] English thesis writing guide
Ansible ad-hoc temporary command
Vant weave - remove (clear) < van button > button component Click to display gray background effect
Kwai reached out to the "supply side" to find the "source" of live broadcast e-commerce?
Text classification using huggingface
画画水族馆的应用特色及功能
Mysql 监控3
Cookie加密15 登录加密
[535. encryption and decryption of tinyurl]
cookie加密11
Varnish 基础概览1
Database application