프로그래밍/알고리즘
백준 알고리즘 8958번 OX퀴즈!!
허니팁
2017. 10. 7. 10:42
728x90
반응형
문제는 다음과 같습니다.
https://www.acmicpc.net/problem/8958
import java.util.Scanner; public class Test8958 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); sc.nextLine(); for(int i=0; i<n; i++) { String input = sc.nextLine(); int result=0; int score=0; for(int j=0; j<input.length(); j++) { if(input.charAt(j)=='O') { score++; result +=score; }else { score=0; } } System.out.println(result); } } }
결과는 다음과 같습니다.
728x90
반응형