当前位置:网站首页>Find all prime numbers between 100 and 200
Find all prime numbers between 100 and 200
2022-06-22 12:09:00 【Sainbo】
#include<stdio.h>
#include<windows.h>
// Solutions ,i Set initial value 100 It is accumulated after not counting once , Because prime numbers only have 1 And its two prime numbers , set up t For 1 and i Divisor other than itself , If the integer is false 0, End in turn . Otherwise it's true 1, If one time is true, the output is stopped , Avoid multiple t Divided by i Repeat output
void test1()
{
int i, t;
for(i = 100; i <= 200; i++)
{
for(t = 2; t < i; t++)
{
if(i % t == 0) break;
else
printf("%d、", i); /* The test uses Chinese registration number , feasible */
break;
}
}
printf(" Prime number !\n");
}
void test2()
{
int i = 100, t = 2;
while(i < 200)
{
i++;
while(t < 199)
{
if(i % t == 0) break;
else if(i % t == 1) printf("%d ", i);
break;
t++;
}
}
printf(" Prime number \n");
}
void test3()
{
int i = 100, t = 2;
do
{
i++;
do
{
if(i % t == 0) break;
else if(i % t == 1) printf("%d ", i);
break;
t++;
} while(t < 199);
} while(i < 200);
printf(" Prime number \n");
}
void main()
{
test1();
test2();
test3();
system("pause");
}

边栏推荐
- 成功案例 | 安超云助力兰州大学第二医院搭建新型IT基础设施平台 提升医疗信息资源利用率
- NOI使用案例
- Local raw file contains
- Kruskal reconstruction tree
- CAT敏捷团队教练工作坊 (Coaching Agile Teams) | 8月20日开课
- Typical life cycle model of information system project
- Arc128 C convex hull optimized suffix and?
- Promise upgraded async, await is coming, which is more fragrant with try+catch
- Redis - 5. Jedis operation redis6
- Redis - 7. Opérations de transaction
猜你喜欢

HMS Core新闻行业解决方案:让技术加上人文的温度

马尔可夫链(Markov Chain),隐马尔可夫模型

What is homology??? Cross domain error??? How to solve???

《梦华录》成吸金王:广告主投500万排不上队,腾讯视频赢麻了?

Utilisation de la classification knn de Matlab (avec code source), réalisation de la classification des pixels (auto - réglage de l'échelle de l'ensemble de formation), précision de l'essai d'impressi

牛客挑战赛53C

About cache exceptions: solutions for cache avalanche, breakdown and penetration

OceanBase数据库助力理想汽车智能生产线 可实现30秒内自动恢复

分享7个免费超清的影视资源站!不管是剪辑还是珍藏都实用到哭!

Redis - 10. Master slave replication
随机推荐
About cache exceptions: solutions for cache avalanche, breakdown and penetration
Configure the GPU version of pytorch and torchvision, and learn the GPU version of torch step
Duanyongping, the "Buffett of China": a wise investment
[CISCN2019 总决赛 Day1 Web4]Laravel1
Redis - 5. Jedis operation redis6
Redis - 11、集群(Cluster)
Markov chain, hidden Markov model
IO之Reader案例
Collection of IO operation cases
求100-200之间全部的素数
Software architecture design principles
Macro definition usage and typedef and Const
[WMCTF2020]Make PHP Great Again 2.0
IO之Reader案例
redisTemplate序列化
Take Wei Lai to court. What's Audi's hurry?
国外LEAD需要干劲、兴趣、钻研、勤奋、缺一不可
Reader case of IO
Word技巧汇总
Redis - 11. Cluster