#include <iostream>
using namespace std;
int main() {
int time,a=0,b=0,t=0,tt=0,k=0,u =0;
cin>>time;
cin.get();
for(int i=0;i<time;i++)
{
char n[1000000]={},p[1000000]={};
cin.getline(n,200);
while(1){
if(n[u]!='p'&&n[u]!='q'&&n[u]!='.')
break;
p[t] = n[u];
u = u+1;
if(p[t]=='.'){
continue;
}
if(p[t]=='p')
a = 1;
if(a==1&&p[t]=='q')
{
tt = tt+1;
a = 0;
b = 0;
t = t-2;
if(p[t]=='p')
a = 1;
}
t = t+1;
}
cout<<tt<<endl;
t = 0;
u = 0;
tt = 0;
}
}
後來發現getline()的數字開成200但改了之後還是有一些問題,
#0: 20% WA (line:2)
您的答案為: 9 正確答案為: 8#1: 20% WA (line:2)
您的答案為: 34 正確答案為: 33#2: 20% WA (line:6)
您的答案為: 962 正確答案為: 961#3: 20% WA (line:2)
您的答案為: 19703 正確答案為: 19702#4: 20% WA (line:1)
您的答案為: 799452 正確答案為: 1998788
喔對,我開的陣列大小有改過