2015年9月2日 星期三

無聊打發時間 UVA 1585 C++

#include<iostream>
#include<string>
using namespace std;
int main()
{

int times,answer,tmp;
string input;
cin >> times;
for (int i = 0; i < times; i++)
{
answer = 0;
tmp = 0;
cin >> input;
for (int j = 0; j < input.length(); j++)
{
if (input[j] == 'X')
tmp = 0;
else
{
tmp = tmp + 1;
answer = answer + tmp;
}
}
cout << answer << endl;
}
return 0;
}

沒有留言:

張貼留言