当前位置:网站首页>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");
}

边栏推荐
- Markov chain, hidden Markov model
- TiFlash 函数下推必知必会丨十分钟成为 TiFlash Contributor
- arc128 C 凸包优化后缀和?
- Redis - 10. Master slave replication
- Redis - 11、集群(Cluster)
- In C # development, the third-party components lambdaparser, dynamicexpresso and z.expressions are used to dynamically parse / evaluate string expressions
- Fight, programmer - Chapter 37 The Xiongguan pass is like an iron road. Now, I'm going to cross it from the beginning
- CF736 D2
- Cosmos、Polkadot
- IO之Reader案例
猜你喜欢

鉴权之cookie、session、JWT

机器学习与深度学习 --- 激活函数(未完待续)

APM flight mode switching -- source code explanation

Redis - 3、发布和订阅

Deadlock found when trying to get lock; try restarting transaction 【MySQL死锁问题解决】

Differences between SPI and API

Word技巧汇总

Duanyongping, the "Buffett of China": a wise investment

HMS core news industry solution: let technology add humanistic temperature

本地裸文件包含
随机推荐
Interpretation of basic requirements for classified protection of network security (GBT 22239-2019)
Matlab的KNN分类使用(附源码),实现像素分类(自己设置训练集比例),打印测试精度
APM set pitch four rotor control mode
maxscale在mariadb主从切换后如何处理event的状态-handle_events
More than half of 2022, no new air outlet
"Dare not doubt the code, but have to doubt the code" a network request timeout analysis
鉴权之cookie、session、JWT
Haas506 2.0 development tutorial - Advanced Component Library -modem Info (only supports versions above 2.2)
分享7个免费超清的影视资源站!不管是剪辑还是珍藏都实用到哭!
Call center CTI system
Messari年度报告-2022
TiFlash 函数下推必知必会丨十分钟成为 TiFlash Contributor
Solution to 94d problem of Niuke practice match
Differences between SPI and API
In a word, several common methods of uploading Trojan horse
云上人和物联科技加入龙蜥社区,携手打造软硬件服务生态
软件架构设计原则
Set up OpenPGP key server
国外LEAD需要干劲、兴趣、钻研、勤奋、缺一不可
Solution to 57c of Niuke challenge