您的位置:首页 > 其它

1.打印100~200之间的素数/2.判断1000年-2000年之间的闰年

2017-03-06 15:41 519 查看
//打印100-200之间的素数
#include<stdio.h>
int main()
{
int i = 0;
int count = 0;
for (i = 100; i <= 200; i++)
{
int j = 0;
for (j = 2; j <= i - 1; j++)
{
if (i%j == 0)
break;
}
if (j >= i - 1)
{
count++;
printf("%d ", i);
}
}
printf("\ncount=%d\n",count);
return 0;
}




//判断1000-2000之间的闰年
#include<stdio.h>
int main()
{
int count = 0;
int year = 0;
for (year = 1000; year <= 2000;year++)
if (((year % 4 == 0) && (year % 100 != 0)) || (year%400==0))
{
count++;
printf("%d ", year);
}
printf("\ncount = %d\n ", count);
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: