結果
問題 | No.49 算数の宿題 |
ユーザー | Himatsubushin |
提出日時 | 2022-01-04 09:07:57 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 700 bytes |
コンパイル時間 | 321 ms |
コンパイル使用メモリ | 28,144 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-08-24 17:50:57 |
合計ジャッジ時間 | 690 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 0 ms
4,380 KB |
testcase_02 | AC | 0 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 0 ms
4,376 KB |
testcase_05 | AC | 1 ms
4,380 KB |
testcase_06 | AC | 0 ms
4,376 KB |
testcase_07 | AC | 1 ms
4,376 KB |
testcase_08 | AC | 1 ms
4,384 KB |
testcase_09 | AC | 0 ms
4,384 KB |
ソースコード
#include <stdio.h> #include <string.h> int main(int argc, const char * argv[]) { char string[101], operator = '\0'; int i, accumulator, number; accumulator = number = 0; scanf("%s", string); for (i = 0; i <= strlen(string); i++) { if (string[i] < '0' || string[i] > '9') { switch (operator) { case '*': accumulator += number; break; case '+': accumulator *= number; break; case '\0': accumulator = number; break; } operator = string[i]; number = 0; } else { number = number * 10 + (int)(string[i] - '0'); } } printf("%d\n", accumulator); return 0; }