結果

問題 No.784 「,(カンマ)」
ユーザー takahiro-serikawa
提出日時 2019-05-01 12:15:14
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 301 bytes
コンパイル時間 732 ms
コンパイル使用メモリ 20,992 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-31 12:18:24
合計ジャッジ時間 1,011 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:7:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%s", N);
      |         ^~~~~~~~~~~~~~

ソースコード

diff #

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

int main()
{
	char N[11];
	scanf("%s", N);

	int l = strlen(N);
	int n = l % 3;
	if (n > 0)
		fwrite(N, 1, n, stdout);
	for ( ; n < l; n += 3) {
		if (n > 0)
			fwrite(",", 1, 1, stdout);
		fwrite(N+n, 1, 3, stdout);
	}
	fwrite("\n", 1, 1, stdout);
	return 0;
}
0