标题:请高手帮我改下下程序
只看楼主
caiyakang
Rank: 2
等 级:新手上路
威 望:5
帖 子:2111
专家分:0
注 册:2005-3-24
 问题点数:0 回复次数:1 
请高手帮我改下下程序
#include <stdio.h>
void main()
{int m,i,k;
for(m=1;m<=200;m++)
{
k=sqrt(m);
for(i=2;i<=k;i++)
if(m%i==0)break;
if(i>k)printf("%d是素数\n",m);
else printf("%d是合数\n",m);
}
}
改成素数为一行,合数为一行
搜索更多相关主题的帖子: 素数 合数 printf 
2005-08-13 19:59
84009030
Rank: 1
等 级:新手上路
帖 子:191
专家分:0
注 册:2005-5-19
得分:0 
用两维数组第一列存放素数,第二列存放合数,然后分别输出

用了sqrt()函数加上math.h这个头文件

/* HELLO.C -- Hello, jat chan */ #include \"stdio.h\" #include \"conio.h\" main() { printf(\"Hello, jat chan\\n\"); getch(); }
2005-08-13 20:59



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-25069-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.683162 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved