結果
問題 | No.222 引き算と足し算 |
ユーザー |
|
提出日時 | 2017-09-07 18:59:39 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,418 bytes |
コンパイル時間 | 776 ms |
コンパイル使用メモリ | 98,276 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-07 11:06:49 |
合計ジャッジ時間 | 1,768 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:67:9: warning: ‘op’ may be used uninitialized [-Wmaybe-uninitialized] 67 | if(op)cout<<stoi(a)+stoi(b)<<endl; | ^~
ソースコード
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <valarray> #include <vector> #define MOD 1000000007 #define pe(str) return cout<<(str)<<endl,0 #define px(str) {cout<<(str)<<endl;exit(0);} #define pr(str) cout<<(str)<<endl #define prpr(str) cout<<str<<endl #define db(str) cerr<<(str)<<endl #define dbdb(str) cerr<<str<<endl #define re(i,n) for(int i=0;i<(n);i++) #define rep(i,a,b) for(int i=(a);i<(b);i++) #define bw(a,b,c) (((a)<=(b))&&((b)<=(c))) #define spr(a) setprecision(a) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int,int> pii; template<class InputIterator> void dump(InputIterator first,InputIterator last,char delim=' '){ for(InputIterator it=first;it!=last;it++){ if(it!=first)cout<<delim; cout<<*it; } } int main(void){ string s; string a,b; int op; cin>>s; rep(i,1,s.size()){ if(s[i]=='+'){ op=0; a=s.substr(0,i); b=s.substr(i+1); break; } else if(s[i]=='-'){ op=1; a=s.substr(0,i); b=s.substr(i+1); break; } } if(op)cout<<stoi(a)+stoi(b)<<endl; else cout<<stoi(a)-stoi(b)<<endl; return 0; }