1003. 我要通过!(20)
1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 char s[1001]; 6 int i, n, a, b, c; 7 char *p; 8 scanf("%d", &n); 9 for (i = 0; i<n; i++) 10 { 11 scanf("%s", &s); 12 if (strcmp(s, "PAT")==0){ 13 printf("YES\n"); 14 continue; 15 } 16 17 a = b = c = 0; 18 p = s; 19 while (*p == 'A'){ 20 //a的部分 21 a++; 22 p++; 23 } 24 if (*p == 'P'){ 25 p++; 26 while (*p == 'A'){ 27 //b的部分 28 b++; 29 p++; 30 } 31 if (*p == 'T'){ 32 p++; 33 while (*p == 'A'){ 34 //c的部分 35 c++; 36 p++; 37 } 38 if (!(*p) && b>0 && c == a*b){ 39 printf("YES\n"); 40 continue; 41 } 42 } 43 } 44 printf("NO\n"); 45 } 46 return 0; 47 }