結果
問題 | No.222 引き算と足し算 |
ユーザー |
![]() |
提出日時 | 2018-03-14 03:03:27 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 365 bytes |
コンパイル時間 | 577 ms |
コンパイル使用メモリ | 57,820 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-24 17:38:22 |
合計ジャッジ時間 | 1,783 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
ソースコード
#include<iostream> #include<string> using namespace std; int main(){ string str; int x,y,ans,i; cin >> str; for(i=1;i<str.length();i++){ if(str[i] == '+' || str[i] == '-') break; } x = stoi(str.substr(0,i)); y = stoi(str.substr(i+1)); if(str[i] == '+') ans = x-y; else ans = x+y; cout << ans << endl; return 0; }