HDU 1229 还是A+B(A+B陶冶情操)

题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1229

解题报告:A+B

 1 #include<cstdio>
 2 
 3 int main()
 4 {
 5     int a,b,k;
 6     while(scanf("%d%d%d",&a,&b,&k) && !(a == b && a == 0))
 7     {
 8         int sum = a + b;
 9         while(a % 10 == b % 10 && k)
10         {
11             k--;
12             a /= 10;
13             b /= 10;
14         }
15         printf(k <= 0? "-1
":"%d
",sum);
16     }
17     return 0;
18 }
View Code
原文地址:https://www.cnblogs.com/xiaxiaosheng/p/3612238.html