| ||||||||||
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啊,老是wa,用的字符串,跟用fun的对过了。不知道怎么还是wa,贴代码求助#include<stdio.h> #include<string.h> int main() { int n,lb,i,j,k,sa,sb; char a[20],b[20]; scanf("%d",&n); while(n--){ scanf("%s%s",a,b); sa=sb=0; while(a[sa]=='0') sa++; while(b[sb]=='0') sb++; for(i=strlen(a);i<20;i++) a[i]='0'; lb=strlen(b); for(i=sb,j=sa;i<lb;i++,j++){ a[j]+=b[i]-'0'; if(a[j]>'9'){ a[j]-=10; a[j+1]++; } } i=0; while(a[i]=='0') i++; j=19; while(a[j]=='0') j--; for(k=i;k<=j;k++) printf("%c",a[k]); 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