rueki
BOJ 2908. 상수 본문
728x90
반응형
2908번: 상수
상근이의 동생 상수는 수학을 정말 못한다. 상수는 숫자를 읽는데 문제가 있다. 이렇게 수학을 못하는 상수를 위해서 상근이는 수의 크기를 비교하는 문제를 내주었다. 상근이는 세 자리 수 두
www.acmicpc.net
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main()
{
string n1, n2;
cin >> n1 >> n2;
reverse(n1.begin(), n1.end());
reverse(n2.begin(), n2.end());
int r_n1 = stoi(n1);
int r_n2 = stoi(n2);
int result = max(r_n1, r_n2);
cout << result;
return 0;
}
string의 reverse : 문자열 뒤집어준다.
stoi : string to int - 타입 변경해줌
728x90
반응형
'C, C++ 문제풀이' 카테고리의 다른 글
BOJ 1681. 줄 세우기 (0) | 2021.01.01 |
---|---|
BOJ 1427. 소트인사이드 (0) | 2020.12.24 |
BOJ 2501.약수 구하기 (0) | 2020.12.22 |
BOJ 5635. 생일 (0) | 2020.12.22 |
BOJ 14719 . 빗물 (0) | 2020.10.26 |