The original https://pintia.cn/problem-sets/994805260223102976/problems/994805323154440192
My code
# include & lt; Iostream>
using namespace std;
Int main (void)
{
int n;
Cin> & gt; n;//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- input n
for(int i=0; i{
Cin. Sync ();
Cin. The clear ();//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- empty buffer
Int a=0, b=0, c=0, * flag, cp=0, ct=0;//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- the third rule in the topic, with a, b, c three int to store a number of different position, number of cp, cp is used to record the T, P
Flag=& amp; a;//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- initialized flag pointer to a (starting from a
Char t;//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
temporary variablesWhile ((t=cin. The get ())!=(EOF)
{
If (t!
='A'){
If (t=='P' & amp; & (! Cp))
{
Flag=& amp; b;
Cp++;
}//-- -- -- -- -- -- -- -- -- -- -- -- -- -- when read into P, that a string has been finished, at this time would hand flag to point b, after start reading b string in a number of
The else
{
If (t=='t' & amp; & (! Ct) & amp; & Cp)
{
Flag=& amp; C;
Ct++;
}//-- -- -- -- -- -- -- -- -- -- when read again after reading P T, b series has been finished, at this time would hand flag to point c, then start reading c string in A number of
The else
{
If (t=='\ n')
If (c==b * a& & b> 0 & amp; & Cp==ct& & Cp==1)//if the newline character and meet the conditions, the output YES
Cout<" YES "& lt;The else
Cout<" NO "& lt;The else
Cout<" NO "& lt;break;
}
}
}
The else
(* flag) + +;//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- if you have read is A, will be the flag Pointers int++, on behalf of A, b, c to each string contains A number of
}
}
return 0;
}
0 points, all the answers wrong, but don't know what the problem is, help sigh agghh ~
CodePudding user response:
The topCodePudding user response:
Wrong rules, natural all wrong ~ ~ ~ the PTA, when...
#include
#include
Int main () {
Int n, I, j;
Int CNTP=0, CNTT=0, CNTA=0, flag=1;
P1, char * * p2.
The scanf (" % d ", & amp; N);
Char s [10] [100].
for(i=0; iThe scanf (" % s ", s [I]);
for(i=0; i{
Flag=1;
CNTP=CNTA=CNTT=0;
//count P, A, the number of T, if you have other characters NO; Rules of [1]
for(j=0; S [I] [j].='\ 0'; J++)
{
If (s [I] [j]=='P') cntp++;
Else if (s [I] [j]=='A') cnta++;
Else if (s [I] [j]=='T') cntt++;
The else {flag=2; break; }
}
//there is only 1 P and T, at least 1 A; Rules of [2]
If (flag==1 & amp; & CNTP==1 & amp; & CNTT==1 & amp; & CNTA!=0)
{
P1=STRCHR (s [I], "P");
P2=STRCHR (s [I] 'T');
//aPbATca refers to: (A number) in front of the P * (P T between A number of)==T behind A number of; [3]
If ((p1 - s [I]) * (p2 - p1-1)==strlen (p2) - 1)
flag=0;
}
If (flag==0) puts (" YES ");
The else puts (" NO ");
}
return 0;
}