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<cstring> using namespace std; int big,d[4][1000],k,m,n,s; char a[3][10]; void add() { int p=0; for(int i=0;i<big;i++) { d[s][i]=d[k][i]+d[m][i]+d[n][i]+p; p=d[s][i]/10; if(d[s][i]>9) d[s][i]%=10; } if(p) {d[s][big]=p;big++;} } void f() { int len=strlen(a[0]),big=len; for(int i=0;i<len;i++) d[0][i]=a[0][len-i-1]-'0'; len=strlen(a[1]); if(big<len) big=len; for(int i=0;i<len;i++) d[1][i]=a[1][len-i-1]-'0'; len=strlen(a[2]); if(big<len) big=len; for(int i=0;i<len;i++) d[2][i]=d[2][len-i-1]-'0'; for(int i=0;i<97;i++) { k=i%4; m=(i+1)%4; n=(i+2)%4; s=(i+3)%4; add(); } } int main() { while(scanf("%s%s%s",&a[0],&a[1],&a[2])!=EOF) { f(); for(int i=0;i<big;i++) cout<<d[s][big-i-1]; cout<<endl; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator