标签:des style java color os strong
1 2 1 11 21 1 108 8 2 36 64 3 0 0 1
3 -1 -1 100
思路:用%得到数字的末尾位就可以了,再用一个flag进行标记,判断怎样跳出循环的
#include<stdio.h> int main() { int A,B,K,sum; while(scanf("%d%d%d",&A,&B,&K)&&A!=0&&B!=0) { int i,temp,a,b; sum=A+B; for(i=0,temp=0;i<K;i++) { a=A%10; b=B%10; if(a==b) { A/=10; B/=10; } else { temp=1; break; } } if(temp) printf("%d\n",sum); else printf("-1\n"); } return 0; }
标签:des style java color os strong
原文地址:http://blog.csdn.net/qq_16767427/article/details/38037001