[boj] (b2) 2908 상수

강신현·2022년 3월 31일
0

✅ stoi()

문제

링크

코드

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    string str1, str2;
    cin >> str1 >> str2;

    char tmp;
    tmp = str1[0];
    str1[0] = str1[2];
    str1[2] = tmp;

    tmp = str2[0];
    str2[0] = str2[2];
    str2[2] = tmp;

    if (stoi(str1) < stoi(str2)) cout << str2 << "\n";
    else
        cout << str1 << "\n";

    return 0;
}
profile
땅콩의 모험 (server)

0개의 댓글