http://www.patest.cn/contests/pat-b-practise/1016
简单题,注意字符数字与一般数字的比較即可了,看代码。。
#include<stdio h=""> #include <string h=""> int main() { int m,n; int i,j; char a[100],b[100]; while(scanf("%s %d %s %d",&a,&m,&b,&n)!=EOF) { int len1=0; int len2=0; int count1=0,count2=0; int A=0,B=0; int q=0,p=0; len1=strlen(a); len2=strlen(b); for(i=0;i<len1+1;i++) { if(a[i]-'0'==m) { count1++; } } for(i=0;i<len2+1;i++) { if(b[i]-'0'==n) { count2++; } } if(count1!=0||count2!=0) { A=m; B=n; for(i=1;i<count1;i++) { A=m+A*10; } for(i=1;i<count2;i++) { B=n+B*10; } // printf("%d %d",count1,count2); //printf("%d %d",A,B); printf("%d\n",A+B); } else printf("0\n"); } } </string></stdio>