UVA1585

#include
int main()
{   int n,temp=0;//temp是一个标志变量,标志上一个字符是不是O
	int score=0;
	char c;
	scanf("%d",&n);
	while(n--)
	{	 
		getchar();
		while(scanf("%c",&c)&&c!='\n')
		{
			if(c=='O')
			{
				if(temp) 
				{	temp+=1;
					score+=temp;
				}
		 		else 
				{
					score+=1;
					temp=1;
				}
			}	
			else 
				temp=0;

			
		}
	printf("%d\n",score);
	score=0;
	}
	
return 0;
}

你可能感兴趣的:(C语言)