C语言实验——素数 (sdut oj)

来源:互联网 发布:js实现二维码生成 编辑:程序博客网 时间:2024/06/08 01:05


C语言实验——素数

Time Limit: 1000MS Memory Limit: 65536KB



Problem Description

输出100->200之间的素数的个数,以及所有的素数。


Input


Output

100->200之间的素数的个数,以及所有的素数。


Example Input

Example Output

21101 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;}


0 0
原创粉丝点击