본문 바로가기
  • Let's study
PS/백준

[C++] 백준 21638: SMS from MCHS

by 코딩고수이고파 2023. 5. 6.

문제

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

 

21638번: SMS from MCHS

The first line of input contains two integers $t_1$ and $v_1$ --- the temperature and the wind speed for today ($-50 \le t_1 \le 50$; $0 \le v_1 \le 20$). The second line contains two integers $t_2$ and $v_2$ --- the temperature and the wind speed for tomo

www.acmicpc.net

 

해결방법

오늘과 내일의 온도와 풍속을 비교하여 적절한 조건마다 올바른 문장을 출력해주면 된다. 

 

코드

#include<iostream>

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int t1, v1, t2, v2;
	cin >> t1 >> v1 >> t2 >> v2;

	if (t2 < 0 && v2 >= 10)
		cout << "A storm warning for tomorrow! Be careful and stay home if possible!";
	else if (t2 < t1)
		cout << "MCHS warns! Low temperature is expected tomorrow.";
	else if (v2 > v1)
		cout << "MCHS warns! Strong wind is expected tomorrow.";
	else
		cout << "No message";

	return 0;
}

댓글