728x90

4999번: 아!
입력은 두 줄로 이루어져 있다. 첫째 줄은 재환이가 가장 길게 낼 수 있는 "aaah"이다. 둘째 줄은 의사가 듣기를 원하는 "aah"이다. 두 문자열은 모두 a와 h로만 이루어져 있다. a의 개수는 0보다 크거
www.acmicpc.net
#include <iostream>
#include <string>
using namespace std;
string maximum;
string input;
int maxcnt = 0;
int cnt = 0;
int main() {
cin >> maximum;
cin >> input;
for (int i = 0; i < maximum.length(); i++) {
if (maximum[i] == 'a') {
maxcnt++;
}
else {
break;
}
}
for (int i = 0; i < input.length(); i++) {
if (input[i] == 'a') {
cnt++;
}
else {
break;
}
}
if (maxcnt < cnt) {
cout << "no" << "\n";
}
else if (maxcnt >= cnt) {
cout << "go" << "\n";
}
return 0;
}
728x90
'Algorithm > 백준' 카테고리의 다른 글
[C++] 백준 2480번: 주사위 세개 (0) | 2022.02.16 |
---|---|
[C++] 백준 2525번: 오븐 시계 (0) | 2022.02.15 |
[C++] 백준 11719번: 그대로 출력하기 2 (0) | 2022.02.14 |
[C++] 백준 11718번: 그대로 출력하기 (0) | 2022.02.14 |
[C++] 백준 15596번: 정수 N개의 합 (0) | 2022.02.13 |
댓글