結果
問題 | No.49 算数の宿題 |
ユーザー |
|
提出日時 | 2022-01-04 09:07:57 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 700 bytes |
コンパイル時間 | 784 ms |
コンパイル使用メモリ | 29,312 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 02:16:17 |
合計ジャッジ時間 | 761 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
#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;}