結果

問題 No.784 「,(カンマ)」
ユーザー leaf+
提出日時 2019-04-13 19:19:31
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 358 bytes
コンパイル時間 686 ms
コンパイル使用メモリ 56,824 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-15 11:18:19
合計ジャッジ時間 1,382 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
using namespace std;

int main() {
    string ans;
    int i;
    long n;
    cin >> n;
    if (n == 0) {ans = "0";}
    for (i = 0; n > 0; i++) {
        if (i != 0 && i % 3 == 0) {
        	ans = "," + ans;
        }
        ans = to_string(n % 10) + ans;
        n /= 10;
    }
    cout << ans << endl;
   return 0;
}
0