문제 출처 : https://www.acmicpc.net/
#8958: OX퀴즈 (언어 : Java11)

제출 답안
import java.util.*;
class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
for(int i=0; i<num; i++){
String ox = sc.next();
int result = 0;
int count = 1;
for(int j=0; j<ox.length(); j++){
if(ox.substring(j,j+1).equals("O"))
result += count++;
else
count = 1;
}
System.out.println(result);
}
}
}
comment
-
'Study📚 > 백준' 카테고리의 다른 글
[백준] - #1157: 단어 공부 (0) | 2024.05.27 |
---|---|
[백준] - #2839: 설탕 배달 (0) | 2024.05.27 |
[백준] - #2525: 오븐 시계 (0) | 2024.05.25 |
[백준] - #2577: 숫자의 개수 (0) | 2024.05.22 |
[백준] - #2675: 문자열 반복 (0) | 2024.05.21 |