結果

問題 No.656 ゴルフ
コンテスト
ユーザー Naoki00712
提出日時 2023-06-14 09:10:15
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 616 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 178 ms
コンパイル使用メモリ 38,080 KB
最終ジャッジ日時 2026-02-22 10:47:22
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 6
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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