
#include <iostream>
#include <string>
using namespace std;
int main()
{
string A, B;
cin >> A >> B;
int aSize = A.length();
int bSize = B.length();
string Cal = "";
int overnum = 0;
while (aSize > 0 || bSize > 0)
{
int num1= 0;
if (aSize > 0)
{
num1 = A[--aSize] - '0';
}
int num2 = 0;
if (bSize > 0)
{
num2 = B[--bSize] - '0';
}
int Value = num1 + num2 + overnum;
overnum = Value / 10;
Value %= 10;
char Val = Value + '0';
Cal += Val;
}
if (overnum > 0)
{
Cal += overnum + '0';
}
string Result = "";
for (int i = (int)Cal.length() - 1; i >= 0; --i)
{
Result += Cal[i];
}
cout << Result << "\n";
return 0;
}
'알고리즘 > 백준' 카테고리의 다른 글
부녀회장이 될테야 (2775번) (0) | 2021.07.26 |
---|---|
ACM 호텔 (10250번) (0) | 2021.07.26 |
달팽이는 올라가고 싶다 (0) | 2021.07.26 |
분수 찾기 (0) | 2021.07.26 |
벌집 (0) | 2019.11.06 |