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 |
哪位大哥能帮我看看到底是哪错了啊?谢谢了。#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; cout<<a1<<" "<<a2<<endl; 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