結果
| 問題 | No.784 「,(カンマ)」 | 
| コンテスト | |
| ユーザー |  mas9612 | 
| 提出日時 | 2019-08-02 23:41:48 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 524 bytes | 
| コンパイル時間 | 516 ms | 
| コンパイル使用メモリ | 58,072 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-05 08:20:04 | 
| 合計ジャッジ時間 | 1,146 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 10 | 
ソースコード
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    char result[50];
    int ri = 0;
    for (int i = 0; i < s.length(); ++i) {
        if ((i > 0) && (i % 3 == 0)) {
            result[ri] = ',';
            ++ri;
        }
        result[ri] = s[i];
        ++ri;
    }
    --ri;
    if (result[ri] == ',')
        --ri;
    while (ri >= 0) {
        cout << result[ri];
        --ri;
    }
    cout << '\n';
}
            
            
            
        