处理方式 :
特殊情况提前判断 + 一般情况从首推到尾
#include <iostream>
#include <cstring>
using namespace std;
const int N = 1e2 + 10;
typedef long long LL;
int T;
string s;
int main()
{
cin >> T;
while (T -- )
{
cin >> s;
s = '_' + s + '_';
if (s.size() == 3 && s[1] == '^')
{
cout << 1 << '\n';
continue;
}
int a = 0;
for (int i = 1; i < s.size(); i ++ )
{
if (s[i] != '^' && s[i - 1] != '^') a ++ ;
}
cout << a << '\n';
}
return 0;
}
标签:Name,int,CF,New,Yura,1820A
From: https://www.cnblogs.com/bzdydscjgw/p/17334551.html