Home > Back-end >  PAT (Basic Level) Practice (in Chinese), 1003 I want to pass! (20 points) to ask questions
PAT (Basic Level) Practice (in Chinese), 1003 I want to pass! (20 points) to ask questions

Time:09-25

There are two test points before, very afflictive, consult
 
#include
#include
using namespace std;

Const int N=110;

Int main ()
{
int n;
Char vol [N].
While (the scanf (" % d ", & amp; N)==1 & amp; & n!=0) {
for(int i=0; iThe scanf (" % s ", vol);
Int state=0, acnt=0, BCNT=0, CCNT=0, br=0;//read the state used to store state, 0 means that the unread to P, read to 1 P did not read T, read for 2 T
for(int j=0; JIf (state==0) {
If (vol [j]=='P') {
State++;
}
Else if (vol [j]. {
='A')Printf (" \ n ");
Br++;
break;
}
The else acnt++;
}
Else if (state==1) {
If (vol [j]=='T') {
State++;
}
Else if (vol [j]. {
='A')Printf (" \ n ");
break;
}
The else bcnt++;
}
Else if (state==2) {
If (vol [j]. {
='A')Printf (" \ n ");
break;
}
The else ccnt++;
}
}
if(! Br) {//first determines whether the interrupt
If (CCNT==acnt * bcnt& & BCNT)//is in line with the conditions and A number of not less than 3 1
Printf (" YES \ n ");
The else printf (" \ n ");
}
}
}
//cout & lt; <"Hello world!" return 0;

  • Related