Boj
[2017-10-05] Adding Commas
jwvg0425
2017. 10. 5. 10:46
링크 : https://www.acmicpc.net/problem/5949
숫자 세 자리마다 콤마 하나씩 넣어주는 문제다. 생각하기 귀찮아서 대충 풀었다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <vector> | |
#include <queue> | |
#include <algorithm> | |
#include <iostream> | |
#include <string> | |
#include <bitset> | |
#include <map> | |
#include <set> | |
#include <tuple> | |
#include <string.h> | |
using namespace std; | |
using i64 = long long int; | |
using ii = pair<int, int>; | |
using ii64 = pair<i64, i64>; | |
int main() | |
{ | |
string s; | |
cin >> s; | |
reverse(s.begin(), s.end()); | |
string res; | |
for (int i = 0; i < s.size(); i++) | |
{ | |
res.push_back(s[i]); | |
if (i % 3 == 2 && i != s.size() - 1) | |
res.push_back(','); | |
} | |
reverse(res.begin(), res.end()); | |
cout << res; | |
return 0; | |
} |