結果

問題 No.784 「,(カンマ)」
ユーザー leaf+leaf+
提出日時 2019-04-13 01:02:49
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 406 bytes
コンパイル時間 396 ms
コンパイル使用メモリ 53,828 KB
実行使用メモリ 4,476 KB
最終ジャッジ日時 2023-10-13 09:25:14
合計ジャッジ時間 1,743 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:28: warning: ‘i’ may be used uninitialized in this function [-Wmaybe-uninitialized]
         if ((i != 0) && (i % 3 == 0)) {
                          ~~^~~

ソースコード

diff #

#include <iostream>
#include <string>

int main() {
    int i, j, n;
    std::string ans;
    std::cin >> n;
    while (true) {
        j = n % 10;
        n /= 10;
        ans = std::to_string(j) + ans;
        if ((i != 0) && (i % 3 == 0)) {
            ans = "," + ans;
        }
        i += 1;
        if (n <= 0) {
            break;
        }
    }
    std::cout << ans << std::endl;
    return 0;
}
0