https://www.acmicpc.net/problem/2204
2204번: 도비의 난독증 테스트
꿍은 도비에게 영어단어들을 제시한 후 어떤 단어가 대소문자를 구분하지 않고 사전순으로 가장 앞서는지 맞추면 양말을 주어 자유를 얻게해준다고 하였다. 하지만 인성이 좋지 않은 꿍은 사실
www.acmicpc.net
#include <iostream>
#include <string>
using namespace std;
int main() {
int n;
while (true) {
cin >> n;
if (n == 0)
break;
string* word = new string[n];
string* temp = new string[n];
for (int i = 0; i < n; i++) {
cin >> word[i];
cin.ignore();
temp[i] = word[i];
for (int j = 0; j < temp[i].length(); j++) {
if (temp[i][j] >= 97 && temp[i][j] <= 122)
temp[i][j] -= 32;
}
}
string smallest = temp[0];
int index = 0;
for (int i = 1; i < n; i++) {
if (smallest.compare(temp[i]) > 0) {
smallest = temp[i];
index = i;
}
}
cout << word[index] << endl;
}
}
'Coding > 백준 온라인 저지 (Baekjoon Online Judge)' 카테고리의 다른 글
백준 온라인 저지(Baekjoon Online Judge) - 4948 : 베르트랑 공준 (0) | 2022.12.06 |
---|---|
백준 온라인 저지(Baekjoon Online Judge) - 2563 : 색종이 (0) | 2022.12.06 |
백준 온라인 저지(Baekjoon Online Judge) - 1316 : 그룹 단어 체커 (0) | 2022.12.06 |
백준 온라인 저지(Baekjoon Online Judge) - 12034 : 김인천씨의 식료품가게 (Large) (0) | 2022.12.05 |
백준 온라인 저지(Baekjoon Online Judge) - 12033 : 김인천씨의 식료품가게 (Small) (0) | 2022.12.05 |