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() { int i,j,k,n,m,a1,b1,c1,t,a2,b2,c2,d1; int a[10],b[10],c[10],x=0; char d[100]; while(gets(d)){ if(strcmp(d,"0+0=0")==0) x=1; a1=b1=c1=t=0; k=strlen(d); for(i=0;i<k;i++){ if(d[i]=='+') t=1; else if(d[i]=='=') t=2; if(t==0){ a[a1++]=(d[i]-'0'); } else if(t==1&&d[i]!='+'){ b[b1++]=(d[i]-'0'); } else if(t==2&&d[i]!='='){ c[c1++]=(d[i]-'0'); } } a2=a1;b2=b1;c2=c1; if(a[a2-1]==0){ for(i=a2-1;i>=0;i--){ if(a[i]==0&&a[i-1]!=0) break; } a2=i+1; } if(b[b2-1]==0){ for(i=b2-1;i>=0;i--){ if(b[i]==0&&b[i-1]!=0) break; } b2=i+1; } if(a2>=b2){ for(i=b2;i<a2;i++) b[i]=0; b2=a2; } else{ for(i=a2;i<b2;i++) a[i]=0; a2=b2; } for(i=a2-1;i>=0;i--){ a[i]+=b[i]; } for(i=0;i<a2-1;i++){ if(a[i]>9){ a[i+1]+=1; a[i]=a[i]-10; } } if(a[a2-1]>9){ a[a2-1]=a[a2-1]-10; a[a2++]=1; } d1=0; for(i=0;i<a2;i++){ if(a[i]!=c[i]){ d1=1; break; } } if(a2!=c2) d1=1; if(d1==0) printf("True\n"); else printf("False\n"); if(x==1) break; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator