C语言实验——素数 (sdut oj)
2017-01-25 17:19
211 查看
C语言实验——素数
Time Limit: 1000MS Memory Limit: 65536KB
Problem Description
输出100->200之间的素数的个数,以及所有的素数。
Input
无
Output
100->200之间的素数的个数,以及所有的素数。
Example Input
Example Output
21 101 103 ... 197 199
Hint
Author
ZJGSU参考代码
#include<stdio.h> int main() { int i; int temp; int a = 0; for(i = 100; i <= 200; i++) { for(temp = 2; temp < i; temp++) { if(i%temp == 0) { break; } } if(temp == i) { a++; } } printf("%d\n",a); for(i = 100; i <= 200; i++) { for(temp = 2; temp < i; temp++) { if(i % temp == 0) { break; } } if(temp == i) { printf("%d ",i); } } return 0; }
相关文章推荐
- C语言实验——素数
- C语言实验——用*号输出字母C的图案 (sdut oj)
- C语言实验——拍皮球 (sdut oj)
- C语言实验——保留字母 (sdut oj)
- C语言实验——打印图形 (sdut oj)
- C语言实验——求两个整数之和 (sdut oj)
- C语言实验——for循环打印图形(循环结构)(sdut oj)
- C语言实验——整除 (sdut oj)
- C语言实验——矩阵转置 (sdut oj)
- C语言实验——数组逆序 (sdut oj)
- C语言实验——求一个3*3矩阵对角线元素之和 (sdut oj)
- C语言实验——圆柱体计算 (sdut oj)
- C语言实验——输入数字星期,输出英文(switch语句) (sdut oj)
- C语言实验——计算表达式 (sdut oj)
- C语言实验——两个数最大 (sdut oj)
- C语言实验——分数序列 (sdut oj)
- C语言实验——素数
- C语言实验——各位数字之和排序 (sdut oj)
- C语言实验——求三个整数的最大值 (sdut oj)
- C语言实验——素数