Re: [請益] 誰會c++阿>.<

看板Ju-88作者 (努力..)時間20年前 (2004/04/19 19:58), 編輯推噓4(400)
留言4則, 3人參與, 最新討論串10/11 (看更多)
下面是完整的程式了 我跑過也改過了 你看看吧... 有不懂的地方在問我~ #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

推 61.216.61.49 04/19, , 1F
哇哇!!謝謝囉~^^
推 61.216.61.49 04/19, 1F

推 61.216.141.17 04/19, , 2F
不過,這其實算是C的寫法,並不是C++
推 61.216.141.17 04/19, 2F

推 219.68.105.125 04/19, , 3F
到底是要C還是要C++ =.=?
推 219.68.105.125 04/19, 3F

推210.240.172.123 04/19, , 4F
用C++來寫...^^"
推210.240.172.123 04/19, 4F
文章代碼(AID): #10WxxPmU (Ju-88)
討論串 (同標題文章)
文章代碼(AID): #10WxxPmU (Ju-88)