Re: [問題] ACM 382 Perfection WA -- 已解決

看板C_and_CPP (C/C++)作者 (疾風)時間15年前 (2010/11/07 02:12), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串1/1
遇到的問題: (題意請描述清楚) ACM Q382 WA 希望得到的正確結果: 程式跑出來的錯誤結果: 開發平台: (例: VC++ or gcc/g++ or Dev-C++, Windows or Linux) code block G++ 有問題的code: (請善用置底文標色功能) #include <iostream> #include <iomanip> #include <list> using namespace std; int sqrts(int test); void compare(int val, int com); int main() { int input; int result; list<int> l; cin>>input; while(input != 0) { l.push_back(input); cin>>input; } cout<<"PERFECTION OUTPUT"<<endl; list<int>::iterator iter = l.begin(); while( iter != l.end() ) { result = sqrts(*iter); compare(*iter, result); ++iter; } cout<<"END OF OUTPUT"; return 0; } int sqrts(int test) { int temp = 0; for(int i = 1 ; i < test ; i++) { if(test%i == 0) { temp = temp + i; } } return temp; } void compare(int val, int sum) { if(val > sum) cout<<setw(5)<<val<<" DEFICIENT"<<endl; else if(val == sum) cout<<setw(5)<<val<<" PERFECT"<<endl; else cout<<setw(5)<<val<<" ABUNDANT"<<endl; } ------------------------------ 自己回自己的文 經過了幾次的修改還是WA 不太確定出問題的點在哪裡 麻煩大家幫我看一下 謝謝 -- 我不是宅 我只是比較居家 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 108.21.120.218

11/07 02:25, , 1F
cout<<"END OF OUTPUT"<<endl;
11/07 02:25, 1F

11/07 03:11, , 2F
結果是最後一行沒換行,感謝你~~
11/07 03:11, 2F
文章代碼(AID): #1CrPfuRJ (C_and_CPP)
文章代碼(AID): #1CrPfuRJ (C_and_CPP)