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;
}

猜你喜欢

转载自blog.csdn.net/malazhuzai/article/details/83445993