#5314: WA line:1


CSE911413 (David)


#include <iostream>
using namespace std;
    int main() {
      int n,s,i; 
        while(cin >> n)
          for (i=1; i<n; i++){ 
            if ( n%i==0 ){
              s+=i;
        }
    }

        if(s>n)
            cout << "盈數" << endl;
        else if(s<n)
            cout << "虧數" << endl;
        else if(s=n)
            cout << "完全數" << endl;    
            
       
 return 0;
}
 
 
 
 
這是我的程式碼,試過好幾次都跑不出來,煩請各位高手看一下 
#5319: Re:WA line:1


grd (保持好奇心)


試了一下

應該是卡在while迴圈內出不來..

另外下面判斷式應該是

        else if(s==n)
            cout << "完全數" << endl;   

 沒記錯的話 "="在c應該是附值吧

#5322: Re:WA line:1


CSE911413 (David)


試了一下

應該是卡在while迴圈內出不來..

另外下面判斷式應該是

        else if(s==n)
            cout << "完全數" << endl;   

 沒記錯的話 "="在c應該是附值吧

 

 

 

嗯,"="的部分我之前忘了加上去,那While的部分應如何修改才會跑出來?

抱歉我問題比較多,感謝指教..