[백준] 8958 - OX퀴즈 (파이썬) (C++)
글 작성자: pental

N = int(input()) for i in range(N): score = 0 cnt = 0 result = input() for j in range(len(result)): if result[j] == 'O': cnt += 1 score += cnt elif result[j] == 'X': score += 0 cnt = 0 print(score)
#include <iostream> #include <string> using namespace std; int main() { int num; cin >> num; int *save_total = new int[num]; for (int i = 0; i < num; i++) { string answer; int count = 0; int total = 0; cin >> answer; for (int j = 0; j < answer.size(); j++) { if (answer.at(j) == 'O') { count++; } else { count = 0; } total += count; } cout << total<< "\n"; } }
이 글은
(새창열림)
본 저작자 표시, 비영리 규칙 하에 배포할 수 있습니다. 자세한 내용은 Creative Commons 라이선스를 확인하세요.
Creative Commons
본 저작자 표시
비영리
'Programming > 백준' 카테고리의 다른 글
[백준] 15596 - 정수 N개의 합 (파이썬) (0) | 2020.04.09 |
---|---|
[백준] 4344 - 평균은 넘겠지 (파이썬) (C) (0) | 2020.04.09 |
[백준] 1546 - 평균 (파이썬) (0) | 2020.04.08 |
[백준] 3052 - 나머지 (파이썬) (0) | 2020.04.08 |
[백준] 2577 - 숫자의 개수 (파이썬) (0) | 2020.04.08 |
댓글
이 글 공유하기
다른 글
-
[백준] 15596 - 정수 N개의 합 (파이썬)
[백준] 15596 - 정수 N개의 합 (파이썬)
2020.04.09 -
[백준] 4344 - 평균은 넘겠지 (파이썬) (C)
[백준] 4344 - 평균은 넘겠지 (파이썬) (C)
2020.04.09 -
[백준] 1546 - 평균 (파이썬)
[백준] 1546 - 평균 (파이썬)
2020.04.08 -
[백준] 3052 - 나머지 (파이썬)
[백준] 3052 - 나머지 (파이썬)
2020.04.08
댓글을 사용할 수 없습니다.