※ 글쓴이는 취미로 코딩을 익혀보는 사람이라 정확하지 않은 내용을 담고 있을 수 있다 ※

 

이번에 볼 문제는 백준 4589번 문제인 Gnome Sequencing이다.
문제는 아래 링크를 확인하자.

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

 

4589번: Gnome Sequencing

In the book All Creatures of Mythology, gnomes are kind, bearded creatures, while goblins tend to be bossy and simple-minded. The goblins like to harass the gnomes by making them line up in groups of three, ordered by the length of their beards. The gnomes

www.acmicpc.net

주어지는 서로 다른 세 수가 오름차순 또는 내림차순으로 정렬되어있는지 확인하는 문제이다.

 

세 수 x, y, z를 읽어, x<y<z를 만족하거나 x>y>z를 만족하면 "Ordered", 그렇지 않다면 "Unordered"를 출력해주자.

 

아래는 제출한 소스코드이다.

#include <iostream>
using namespace std;

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

	cout << "Gnomes:\n";
	int T; cin >> T;
	while (T--) {
		int x, y, z; cin >> x >> y >> z;
		if ((x < y && y < z) || (x > y && y > z)) cout << "Ordered\n";
		else cout << "Unordered\n";
	}
}
728x90

'BOJ' 카테고리의 다른 글

[BOJ 4641 // C++] Doubles  (0) 2022.05.29
[BOJ 9046 // C++] 복호화  (0) 2022.05.29
[BOJ 5376 // C++] 소수를 분수로  (0) 2022.05.29
[BOJ 5014 // C++] 스타트링크  (0) 2022.05.29
[BOJ 14936 // C++] 엘리베이터 장난  (0) 2022.05.29

+ Recent posts