結果

問題 No.49 算数の宿題
ユーザー kanpurin002kanpurin002
提出日時 2018-11-14 17:34:48
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 560 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 28,508 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-24 17:40:33
合計ジャッジ時間 973 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

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

int main() {
	long long n=0,m=0;
	int i=0,ope=0;
	char s[101];
	scanf("%s",s);
	while (1) {
		for (m=0;isdigit(s[i]);i++) m=m*10+(s[i]-'0');
		switch (ope) {
			case 1:// 足し算
				n+=m;
				break;
			case 2:// 掛け算
				n*=m;
				break;
			default:
				n=m;
				break;
		}
		switch (s[i++]) {
			case '*':// 足し算
				ope=1;
				break;
			case '+':// 掛け算
				ope=2;
				break;
			default:
				printf("%lld",n);
				return 0;
		}
	}
    return 0;
}
0