結果

問題 No.784 「,(カンマ)」
ユーザー Athena2911Athena2911
提出日時 2019-03-27 20:43:37
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 443 bytes
コンパイル時間 1,121 ms
コンパイル使用メモリ 56,656 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-11 06:13:11
合計ジャッジ時間 1,153 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    string a;
    int ans=0,wow;
    cin>>a;
    wow=a.size()%3;
    for(int i=0;i<wow;i++){
        cout<<a[i];
    }
    if(wow!=0 && a.size()>=3){
        cout<<',';
    }
    for(int i=wow;i<a.size();i++){
        cout<<a[i];
        ans++;
        if(ans==3 && i!=a.size()-1){
            cout<<',';
            ans=0;
        }
    }
    

}
0