반응형
https://www.acmicpc.net/problem/18698
간단 구현 문제였습니다.
📕 풀이방법
📔 입력 및 초기화
test case t, 정답 ans, 문자열 s를 선언 후 입력받습니다.
📔 풀이과정
D또는 문자열의 마지막까지 'U'의 개수를 세줍니다. 이 값을 ans에 더해줍니다.
📔 정답출력
ans를 출력합니다.
📕 Code
#include <bits/stdc++.h>
using namespace std;
int t, ans;
string s;
int main(){
cin >> t;
while(t--){
ans = 0;
cin >> s;
for(auto c : s){
if(c == 'D') break;
ans++;
}
cout << ans << '\n';
}
}
*더 나은 내용을 위한 지적, 조언은 언제나 환영합니다.
'Algorithm > Implementation' 카테고리의 다른 글
(C++) - 백준(BOJ) 9622 : Cabin Baggage (0) | 2022.08.10 |
---|---|
(Rust) - 백준(BOJ) 5087 : Card Cutting (0) | 2022.08.07 |
(C++) - 백준(BOJ) 8806 : Papier kamień nożyczki (0) | 2022.08.03 |
(C++) - 백준(BOJ) 9664 : NASLJEDSTVO (0) | 2022.08.02 |
(Python3) - 백준(BOJ) 14782 : Bedtime Reading, I (0) | 2022.08.01 |