본문 바로가기

Programming/BaekJoon

[C++] 백준 2033번 : 반올림


https://www.acmicpc.net/problem/2033




#include <iostream>

using namespace std;

int main() {

long long n;

cin >> n;


long long tmp=10;

while(n>=tmp)

{

(n%tmp) >= tmp / 2 ? n = ((long long)((int)n / tmp) + 1)*tmp : n = ((long long)(int)n / tmp)*tmp;

tmp *= 10;

cout << n << endl;

}