看板 Ju-88 關於我們 聯絡資訊
下面是完整的程式了 我跑過也改過了 你看看吧... 有不懂的地方在問我~ #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
clovevcat:哇哇!!謝謝囉~^^ 推 61.216.61.49 04/19
Joybo:不過,這其實算是C的寫法,並不是C++ 推 61.216.141.17 04/19
elve:到底是要C還是要C++ =.=? 推 219.68.105.125 04/19
clovevcat:用C++來寫...^^" 推210.240.172.123 04/19