//1003 我要通过! (20分)
pta上的一道题
#include<stdio.h>
#include<string.h>
int main()
{
char c;
int num;
scanf("%d", &num);
while(getchar() != '\n'); //来清除scanf缓存中的垃圾数据
int i=0;//count表示A分别在几个位置 的数量
char pri[num][3];
for(i=0;i<num;i++)
{
int pos=0,count[3]={0,0,0};//,count[3]={0,0,0}不能放上面
while((c=getchar())!='\n'){
if(c=='A') count[pos]++;
else if(c=='P'&&pos==0) pos=1;
else if(c=='T'&&pos==1) pos=2;
else break;
}
if(c=='\n'&&pos==2&&count[1]&&count[2]==count[1]*count[0]){
strcpy(pri[i],"YES");
}
else {
strcpy(pri[i],"NO");
}
if(c!='\n')
while(getchar()!='\n'); //来清除getchar缓存中的垃圾数据
}
for(int j=0;j<num;j++){
printf("%s\n",pri[j]);
}
return 0;
}
我在输出是出現问题
前4ge输出应该只有一个YES,不知道为什么会这么多