結果
問題 | No.708 (+ー)の式 |
ユーザー |
![]() |
提出日時 | 2018-08-13 13:54:22 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 627 bytes |
コンパイル時間 | 503 ms |
コンパイル使用メモリ | 64,736 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-24 07:59:55 |
合計ジャッジ時間 | 1,069 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
コンパイルメッセージ
main.cpp: In function 'int func()': main.cpp:34:1: warning: control reaches end of non-void function [-Wreturn-type] 34 | } | ^
ソースコード
#include<iostream> using ll = long long; using namespace std; string str; int i=0; int func(); int calc(){ int num = func(); while(1){ if(str[i]=='+'){ i++; num+=func(); } else if(str[i]=='-'){ i++; num-=func(); } else return num; } } int func(){ if('0'<=str[i]&&str[i]<='9'){ int res=str[i]-'0'; i++; return res; } if(str[i]=='('){ i++; int res=calc(); i++; return res; } } int main(){ cin >> str; cout << calc() << endl; return 0; }