본문 바로가기

Coding/백준 온라인 저지 (Baekjoon Online Judge)

백준 온라인 저지(Baekjoon Online Judge) - 5656 : 비교 연산자

https://www.acmicpc.net/problem/5656

 

5656번: 비교 연산자

입력은 최대 12000줄로 이루어져 있다. 각 줄은 두 정수 a, b가 주어지며, 정수 사이에는 연산자 ">", ">=", "<", "<=", "==", "!="중 하나가 주어진다. 연산자와 피연산자 사이에는 공백이 하나 있으며, 연

www.acmicpc.net

 

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

int main() {
	string str;

	int a, b;

	int i = 1;

	while (true) {
		cin >> a >> str >> b;
		
		if (str == "E") break;

		cout << "Case " << i << ": ";

		if (str == ">") {
			if (a > b)
				cout << "true" << endl;
			else
				cout << "false" << endl;
		}
		else if (str == ">=") {
			if (a >= b)
				cout << "true" << endl;
			else
				cout << "false" << endl;
		}
		else if (str == "<") {
			if (a < b)
				cout << "true" << endl;
			else
				cout << "false" << endl;
		}
		else if (str == "<=") {
			if (a <= b)
				cout << "true" << endl;
			else
				cout << "false" << endl;
		}
		else if (str == "==") {
			if (a == b)
				cout << "true" << endl;
			else
				cout << "false" << endl;
		}
		else if (str == "!=") {
			if (a != b)
				cout << "true" << endl;
			else
				cout << "false" << endl;
		}

		i++;
	}
}