結果

問題 No.222 引き算と足し算
ユーザー ohreitetsuohreitetsu
提出日時 2018-06-16 17:53:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 692 bytes
コンパイル時間 452 ms
コンパイル使用メモリ 65,452 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-13 06:08:40
合計ジャッジ時間 1,890 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 WA -
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 WA -
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 WA -
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 WA -
testcase_21 AC 2 ms
4,376 KB
testcase_22 WA -
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 WA -
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 WA -
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	string S;
	cin>>S;
	char *pStr=(char*)S.c_str();
	char ch1='+',ch2='+';
	string s1,s2;
	if (pStr[0]=='-' ){
		ch1='-';
		pStr++;
	}
	char op=' ';
	while (*pStr!='\0'){
		if (op==' '){
			if (*pStr>='0' && *pStr<='9'){
				s1.push_back(*pStr++);
			}else{
				op=(*pStr++);
			}
			continue;
		}
		if (*pStr=='-'){
			ch2=(*pStr++);
			continue;
		}
		s2.push_back(*pStr++);
	}
	int data1=atol(s1.c_str());
	int data2=atol(s2.c_str());
	if (ch1=='-'){
		data1=-data1;
	}
	if (ch2=='-'){
		data2=-data2;
	}
	if (op=='+'){
		cout<<data1-data2<<endl;
	}else{
		cout<<data1+data2<<endl;
	}
	return 0;
}
0