[PS 백준 - 1.1] 8958번: OX 퀴즈
문제 정보
- 난이도: 브론즈 2
- 알고리즘: 문자열
코멘트
OX 채점결과를 문자열로 받은 뒤 str.length와 str[j]로 접근하여 점수를 더하는 형식으로 코드를 작성하였다.
소스 코드
#include <iostream>
using namespace std;
int main() {
cin.tie(NULL);
cout.tie(NULL);
std::ios::sync_with_stdio(false);
int n, count = 1, total=0;
cin >> n;
string str;
for (int i = 0; i < n; i++) {
str.clear();
cin >> str;
for (int j = 0; j < str.length(); j++) {
if (str[j] == 'O') {
total += count++;
}
else {
count = 1;
}
}
cout << total << "\n";
count = 1;
total = 0;
}
}
Author And Source
이 문제에 관하여([PS 백준 - 1.1] 8958번: OX 퀴즈), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@yjwon20/PSboj1-1저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)