백준 알고리즘(C/C++) - 8958번 OX퀴즈

 

#include <stdio.h>
int main() {
	int s, n, b;
	char a[80];
	scanf("%d", &n);
	while (n--) {
		b = s = 0;
		scanf("%s", a);
		for (int i = 0; a[i]; i++)
			a[i] == 'O' ? s += ++b : (b = 0);
		printf("%d\n", s);
	}
}
#include <iostream>
int main() {
	int s, n, b;
	char a[80];
	std::cin >> n;
	while (n--) {
		b = s = 0;
		std::cin >> a;
		for (int i = 0; a[i]; i++)
			a[i] == 'O' ? s += ++b : (b = 0);
		std::cout << s << std::endl;
	}
}

 

댓글

Designed by JB FACTORY