結果

問題 No.383 レーティング
ユーザー masakiGitmasakiGit
提出日時 2018-05-03 18:36:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 814 bytes
コンパイル時間 571 ms
コンパイル使用メモリ 66,740 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-10 09:21:13
合計ジャッジ時間 1,446 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
using namespace std;
string trim(string);
int main() {
	char  getline[100];
	string s;
	cin.getline( getline , sizeof(getline));
	s = getline;
	s = trim(s);
	int a = s.find(" ");
	string s1 = s.substr(0, a);
	s1 = trim(s1);
	string s2 = s.substr(a, s.size());
	s2 = trim(s2);
	int num1 = stoi(s1);
	int num2 = stoi(s2);
	int result = num2 - num1;
	if (result > 0) {
		cout << "+" << result << endl;
	}
	else if (result == 0) {
		cout << result << endl;
	}
	else {
		cout << result << endl;
	}
	return 0;
}

string trim(string s) {
	while (true) {
		if (s.substr(0, 1) == " ") {
			s = s.substr(1, s.size() - 1);
		}
		else {
			break;
		}
	}
	while (true) {
		if (s.substr(s.size() - 1, 1) == " ") {
			s = s.substr(0, s.size() - 1);
		}
		else {
			break;
		}
	}
	return s;
}
0