| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
WA代码&&AC代码 不知为何。。。求解答WA代码:
#include <iostream>
using namespace std;
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
int cent;
cin>>cent;
cout<<i<<' '<<cent/25<<" QUARTER(S), "
<<(cent%=25,cent/10)<<" DIME(S), "
<<(cent%=10,cent/5)<<" NICKEL(S), "
<<(cent%=5,cent)<<" PENNY(S)\n";
}
}
AC代码:
#include <iostream>
using namespace std;
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
int cent;
cin>>cent;
cout<<i<<' '<<cent/25<<" QUARTER(S), ";
cent%=25;
cout<<cent/10<<" DIME(S), ";
cent%=10;
cout<<cent/5<<" NICKEL(S), ";
cent%=5;
cout<<cent<<" PENNY(S)\n";
}
}
请问第一个代码为何不能那样写?谢谢了。
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator