結果

問題 No.222 引き算と足し算
ユーザー femto
提出日時 2015-12-20 22:15:07
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 358 bytes
コンパイル時間 511 ms
コンパイル使用メモリ 58,460 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-15 22:08:36
合計ジャッジ時間 1,282 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main() {
	string s;
	cin >> s;
	int opidx = 1;
	while(s[opidx] != '+'&& s[opidx] != '-') opidx++;
	int x = stoi(s.substr(0, opidx));
	int y = stoi(s.substr(opidx + 1, s.size() - opidx));
	if(s[opidx] == '+') {
		cout << x - y << endl;
	}
	else {
		cout << x + y << endl;
	}
}
0