标签:length 时间 ann har system can rar pat lin
19分,有点没懂题目意思,隔段时间再回来看看。
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
scanner.nextLine();
for(int i = 0 ; i < n ; ++i){
String str = scanner.nextLine();
char[] ch = str.toCharArray();
int flagp = 0;
int flaga = 0;
int flagt = 0;
int j;
for( j = 0 ; j < ch.length; ++j){
if((ch[j] == ‘P‘ && flagp == 0) || (ch[j] == ‘A‘ && flaga < 3) || (ch[j] == ‘T‘ && flagt == 0 && flagp > 0) || ch[j] == ‘ ‘){
if(ch[j] == ‘P‘)
flagp ++;
if(ch[j] == ‘T‘)
flagt++;
if(ch[j] == ‘A‘ && flagp > 0 && flagt == 0){
flaga ++;
}
}else{
System.out.println("NO");
break;
}
}
if(j == ch.length ) {
if (flaga > 0 && flagp == 1 && flagt == 1)
System.out.println("YES");
else
System.out.println("NO");
}
}
}
}
标签:length 时间 ann har system can rar pat lin
原文地址:https://www.cnblogs.com/lin0/p/11925080.html