1016. 部分A+B (15)

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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值