A+B Problem(V)
- 描述
- 做了A+B Problem之後,Yougth感覺太簡單了,於是他想讓你求出兩個數反轉後相加的值。幫幫他吧
- 輸入
- 有多組測試數據。每組包括兩個數m和n,數據保證int範圍,當m和n同時爲0是表示輸入結束。
- 輸出
- 輸出反轉後相加的結果。
- 樣例輸入
-
1234 1234 125 117 0 0
- 樣例輸出
-
8642 1232
// 零散的小知識點 把一個數反轉
//代碼如下:
#include <cstdio>
int main()
{
int a,b;
int n,m;
while (~scanf ("%d%d",&a,&b) && a && b)
{
int sum1 = 0;
int sum2 = 0;
while (a)
{
sum1 *= 10; //比如 1234; 循環sum1 的值依次爲 0,4;40,43;430,432;4320,4321;
n = a % 10;
sum1 += n;
a = a / 10;
}
while (b)
{
sum2 *= 10;
m = b % 10;
sum2 += m;
b = b / 10;
}
printf ("%d\n",sum1 + sum2);
}
return 0;
}