1. 程式人生 > >Score UVA - 1585

Score UVA - 1585

#include <stdio.h>
#include <string.h>

int score(const char * str) {
	int a = 0, b = 1;
	for (int i = 0; i < strlen(str); i++) {
		if (str[i] == 'O')
			a += b++;
		else
			b = 1;
	}
	return a;
}

int main() {
	int T;
	char s[100];
	scanf("%d", &T);
	while (T--) {
		scanf("%s", s);
		printf("%d\n", score(s));
	}
	return 0;
}