rueki
BOJ 1357. 뒤집힌 덧셈 본문
728x90
반응형
1357번: 뒤집힌 덧셈
어떤 수 X가 주어졌을 때, X의 모든 자리수가 역순이 된 수를 얻을 수 있다. Rev(X)를 X의 모든 자리수를 역순으로 만드는 함수라고 하자. 예를 들어, X=123일 때, Rev(X) = 321이다. 그리고, X=100일 때, Rev(
www.acmicpc.net
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int Rev(string str)
{
reverse(str.begin(), str.end());
int result = stoi(str);
return result;
}
int main()
{
string a, b;
cin >> a >> b;
int res = Rev(a) + Rev(b);
cout << Rev(to_string(res)) << endl;
return 0;
}
728x90
반응형
'C, C++ 문제풀이' 카테고리의 다른 글
BOJ 1681. 줄 세우기 (0) | 2021.01.01 |
---|---|
BOJ 1427. 소트인사이드 (0) | 2020.12.24 |
BOJ 2908. 상수 (0) | 2020.12.24 |
BOJ 2501.약수 구하기 (0) | 2020.12.22 |
BOJ 5635. 생일 (0) | 2020.12.22 |
Comments