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 |
不好意思纠正一下。In Reply To:哪位大哥能帮我看看到底是哪错了啊?谢谢了。 Posted by:hefei2 at 2006-01-12 11:11:30 #include <iostream> #include <string> using namespace std; int main() { string a1,a2; cin>>a1>>a2; while(a1!="0" && a2!="0") { int l1 = 10 - a1.length(); int l2 = 10 - a2.length(); int carry; carry = 0; int i; for(i=1;i<=l1;i++)a1 = "0" + a1; for(i=1;i<=l2;i++)a2 = "0" + a2; for(i=9;i>=0;i--) { char t1,t2; t1 = a1[i]; t1-='0'; t2 = a2[i]; t2-='0'; if(t1+t2>=10)carry++; } if(carry==0)cout<<"No carry operation."<<endl; else if(carry>1)cout<<carry<<" carry operations."<<endl; else if(carry==1)cout<<"1 carry operation."<<endl; cin>>a1>>a2; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator