結果

問題 No.784 「,(カンマ)」
ユーザー michonz4michonz4
提出日時 2019-12-04 16:02:22
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 377 bytes
コンパイル時間 390 ms
コンパイル使用メモリ 28,540 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-20 13:32:51
合計ジャッジ時間 1,210 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 0 ms
4,376 KB
testcase_02 AC 0 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <string.h>

int main() {
  char s[16], buf[16];
  scanf("%s", s);
  size_t size = strlen(s)-1;

  int j=0;
  for (int i=size; i>=0; i--, j++) {
    if ((j+1)%4==0 && i!=size) {
      buf[j++]=',';
      buf[j]=s[i];
    } else {
      buf[j]=s[i];
    }
  }

  for (int i=j-1; i>=0; i--) {
    printf("%c", buf[i]);
  }
  printf("\n");
  return 0;
}
0