其他分享
首页 > 其他分享> > PAT (Basic Level) Practice (中文) 1003 我要通过!

PAT (Basic Level) Practice (中文) 1003 我要通过!

作者:互联网

题目链接

 

#include<stdio.h>
int qw(char a[])
{
  int b,c,d;

  for(c=0;a[c]!='\0';c++){
    if(a[c]=='P')
      break;
  }
  for(d=0;a[d]!='\0';d++){
    if(a[d]=='T')
      break;
  }
  if(a[d]=='\0'){
    printf("NO\n");
    return 0;
  }
  if(d<=c+1){
    printf("NO\n");
    return 0;
  }
  else{
    for(b=0;b<c;b++)
      if(a[b]!='A'){
        printf("NO\n");
        return 0;
      }
    for(b=c+1;b<d;b++)
      if(a[b]!='A'){
        printf("NO\n");
        return 0;
      }
    for(b=d+1;a[b]!='\0';b++)
      if(a[b]!='A'){
        printf("NO\n");
        return 0;
      }
  }
  if(c*(d-c-1)==b-d-1)
  printf("YES\n");
  else
  printf("NO\n");
  return 0;
}
int main()
{
  char a[101];
  int n;
  scanf("%d",&n);
  while(n--){
    scanf("%s",a);
    qw(a);
  }
  return 0;
}

 

标签:char,PAT,qw,Level,int,Practice,break,printf
来源: https://blog.csdn.net/qq_43448856/article/details/99990211