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 |
2316#include<stdio.h> #include<string.h> int main() { char s1[12],s2[12]; int j; for(j=0;j<11;j++) s2[j]='0'; s2[j]='\0'; int len; while(scanf("%s",s1)==1) { len=strlen(s1); for(int i=0;i<len;i++) { s2[i]=(((s2[i]-'0')+(s1[i]-'0'))%10)+'0';//此处因为s2定义的是char型,所以要加 ‘0’让它变成字符 } } for(j=0;j<len;j++) printf("%c",s2[j]); 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