| ||||||||||
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帮一下,给点数据啊#include <stdio.h> #include <string.h> int main() { int n; int i,j; char n1[100],n2[100],n3[100]; int l,c; int a,b; scanf("%d",&n); while(n--){ scanf("%s %s",n1,n2); for(i=strlen(n1);n1[i-1]=='0';i--); for(j=strlen(n2);n2[j-1]=='0';j--); l=i>j ? i:j; for(c=0,i=0;i<l;i++){ if(n1[i]>='0' && n1[i]<='9')a=n1[i]-'0'; else a=0; if(n2[i]>='0' && n2[i]<='9')b=n2[i]-'0'; else b=0; n3[i]=(a+b+c)%10+'0'; c=(a+b+c)/10; } if(c==1){n3[i]='1';n3[i+1]='\0';} else n3[i]='\0'; for(i=0;n3[i]=='0';i++); while(n3[i]) printf("%c",n3[i++]); printf("\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator