作者elve (努力..)
看板Ju-88
标题Re: [请益] 谁会c++阿>.<
时间Mon Apr 19 11:59:43 2004
下面是完整的程式了 我跑过也改过了 你看看吧...
有不懂的地方在问我~
#include<stdio.h>
bool isPrime(int x)
{
int i;
int tmp = 0;
for(i=2;i<x;i++)
{
if(x%i==0)
tmp = tmp + 1;
}
if(tmp == 0)
return true;
else
return false;
}
void main()
{
int m,n,x;
int c=0 ;
printf("please enter first number:") ;
scanf("%d",&m);
printf("please enter second number:") ;
scanf("%d",&n);
for(x=m;x<=n;x++)
{
if (isPrime(x) == true)
{
c=c+1 ;
}
}
printf("there are %d primes\n",c);
}
--
So go and think about Whatever you need to think about
Go on dream about
Whatever you need to dream about
Then come back to me When you know just how you feel
~★ Avril Lavigne ★~
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 203.204.90.148
1F:→ clovevcat:哇哇!!谢谢罗~^^ 推 61.216.61.49 04/19
2F:→ Joybo:不过,这其实算是C的写法,并不是C++ 推 61.216.141.17 04/19
3F:→ elve:到底是要C还是要C++ =.=? 推 219.68.105.125 04/19
4F:→ clovevcat:用C++来写...^^" 推210.240.172.123 04/19