結果
問題 |
No.222 引き算と足し算
|
ユーザー |
|
提出日時 | 2018-05-03 21:39:59 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 509 bytes |
コンパイル時間 | 594 ms |
コンパイル使用メモリ | 64,768 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-28 00:50:34 |
合計ジャッジ時間 | 1,827 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
ソースコード
#include<iostream> #include<string> using namespace std; int main(){ string s; cin >> s; int i; string first = ""; first += s[0]; for(i = 1;;i++){ if(s[i] == '-' || s[i] == '+'){ break; }else{ first += s[i]; } } char op = s[i++]; string second = s.substr(i); if(op == '+') cout << stoi(first)-stoi(second) << endl; else if(op == '-') cout << stoi(first)+stoi(second) << endl; return 0; }