結果
問題 | No.49 算数の宿題 |
ユーザー |
![]() |
提出日時 | 2016-11-26 01:34:09 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 577 bytes |
コンパイル時間 | 111 ms |
コンパイル使用メモリ | 21,376 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 01:54:41 |
合計ジャッジ時間 | 654 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
#include <stdio.h> #include <stdlib.h> int main() { char c; char n_[6]; int n[50]; char o[50]; int pn_ = 0, pn = 0, po = 0; while ((c = getchar()) != '\n') { if (c == '*') { o[po++] = c; n_[pn_] = '\0'; n[pn++] = atoi(n_); pn_ = 0; } else if (c == '+') { o[po++] = c; n_[pn_] = '\0'; n[pn++] = atoi(n_); pn_ = 0; } else { n_[pn_++] = c; } } n_[pn_] = '\0'; n[pn++] = atoi(n_); int r = n[0]; int i; for (i = 0; i < pn - 1; i++) { if (o[i] == '*') r += n[i + 1]; else r *= n[i + 1]; } printf("%d\n", r); return 0; }