結果

問題 No.369 足し間違い
ユーザー ReERishunReERishun
提出日時 2020-05-18 05:51:16
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 782 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 28,980 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-07-25 03:06:13
合計ジャッジ時間 794 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<stdio.h>

void rr_scanl(int index, int *numBox) {
	char str;
	for (int i = 0; i<index; i++)
		numBox[i] = 0;
	int cnt = 0;
	int mode = 0;
	while (cnt < index) {
		str = getchar();
		if (str == '\n') {
			if (cnt != 0)
				break;
		}
		else if (str < '0' || str > '9') {
			if (str == '-')
				mode = 1;
			else {
				mode = 0;
				cnt++;
			}
		}
		else {
			if(mode == 0)
				numBox[cnt] = numBox[cnt] * 10 + (int)str - (int)'0';
			else
				numBox[cnt] = numBox[cnt] * 10 - ((int)str - (int)'0');
		}
	}
}

int main() {
	
	int yukiAns = 0;
	int ans = 0;
	int num = 0;
	int unit[10000];

	scanf("%d", &num);
	rr_scanl(num, unit);
	scanf("%d", &yukiAns);

	for (int i = 0; i < num; i++)
		ans += unit[i];

	printf("%d", ans - yukiAns);

	// 終了コードは0
	return 0;
}
0