8958번
-
[백준] 8958번: OX퀴즈코딩(Coding)/백준 문제풀이 2020. 12. 24. 09:48
OX퀴즈 문제 "OOXXOXXOOO"와 같은 OX퀴즈의 결과가 있다. O는 문제를 맞은 것이고, X는 문제를 틀린 것이다. 문제를 맞은 경우 그 문제의 점수는 그 문제까지 연속된 O의 개수가 된다. 예를 들어, 10번 문제의 점수는 3이 된다. "OOXXOXXOOO"의 점수는 1+2+0+0+1+0+0+1+2+3 = 10점이다. OX퀴즈의 결과가 주어졌을 때, 점수를 구하는 프로그램을 작성하시오. 해당 문제는 OX결과를 문자열로 받으면 해당 문자열을 읽어서 연속된 O는 점수가 늘어나게하고 X가 나오면 다시 0점을 주고 다시 1로 점수를 세게끔... 그냥 문제 그대로 알고리즘을 구현하면 되는 쉬운문제이다. 나는 그냥 combo라는 변수를 선언해서 그 값만큼 더해주고 combo += 1로 연속된 점수에대한 갱..