結果

問題 No.656 ゴルフ
ユーザー Naoki00712Naoki00712
提出日時 2023-06-14 09:11:06
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 616 bytes
コンパイル時間 1,650 ms
コンパイル使用メモリ 27,768 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-04 23:22:05
合計ジャッジ時間 1,534 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>

int c2score(char c);

int main()
{
	char* S;
	int score = 0;

	S = (char*)malloc(sizeof(char) * 9);

	if (S == NULL) {
		return -1;
	}

	if (scanf("%s", S) != 1) {
		return -1;
	}

	for (int i = 0; i < 9; i++) {
		score += c2score(*(S + i));
	}

	printf("%d", score);

	return 0;
}

int c2score(char c)
{
	switch (c) {
	case '0':
		return 10;
	case '1':
		return 1;
	case '2':
		return 2;
	case '3':
		return 3;
	case '4':
		return 4;
	case '5':
		return 5;
	case '6':
		return 6;
	case '7':
		return 7;
	case '8':
		return 8;
	case '9':
		return 9;
	default:
		return 0;
	}
}
0