結果
| 問題 |
No.49 算数の宿題
|
| コンテスト | |
| ユーザー |
bal4u
|
| 提出日時 | 2019-04-07 22:49:44 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 472 bytes |
| コンパイル時間 | 308 ms |
| コンパイル使用メモリ | 29,184 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-23 02:02:16 |
| 合計ジャッジ時間 | 864 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
// yukicoder: No.49 算数の宿題
// 2019.4.7 bal4u
// 構文解析
#include <stdio.h>
#include <ctype.h>
char s[105];
char *num(int *n, char *p)
{
int k = 0;
while (isdigit(*p)) k = 10 * k + (*p++ & 0xf);
*n = k;
return p;
}
int main()
{
int x, op, ans;
char *p;
scanf("%s", s);
p = num(&ans, s);
while (*p) {
if (isdigit(*p)) {
p = num(&x, p);
if (op == '*') ans += x;
else ans *= x;
}
else op = *p++;
}
printf("%d\n", ans);
return 0;
}
bal4u