标题:判断质数
只看楼主
huanguyu
Rank: 1
等 级:新手上路
帖 子:90
专家分:0
注 册:2006-4-26
得分:0 

# include <iostream.h>
void main()
{
int x;
cout<<"please input x:\n";
cin>>x;
if(x==1) cout<<"1是素数";
else
{
for( int i=2;i<x;i++)
if(x%i==0) break;
if(x==i) cout<<x<<"是素数";
else cout<<x<<"不是素数";}
}//


看越多书就发现自己越无知 于是就越想知道更多
2006-07-16 11:38
穆扬
Rank: 1
等 级:禁止发言
帖 子:1910
专家分:0
注 册:2006-6-1
得分:0 
提示: 作者被禁止或删除 内容自动屏蔽

2006-07-16 13:23



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




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

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