刚开始一直Runtime Error搞了半天是把Scanner sc = new Scanner(System.in);这一句放在while里面了
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(true) {
int t=sc.nextInt();
if(t==-1)break;
System.out.println("Round "+t);
int[] a=new int[26];
String s1=sc.next();
String s2=sc.next();
int count_s1=0;
int count=0;
for (int i = 0; i < s1.length(); i++) {
a[s1.charAt(i)-'a']++;
count_s1++;
}
for (int i = 0; i < s2.length(); i++) {
if(a[s2.charAt(i)-'a']!=0) {
count_s1-=a[s2.charAt(i)-'a'];
a[s2.charAt(i)-'a']=0;
if(count_s1==0) {
break;
}
}else {
count++;
if(count>=7) {
System.out.println("You lose.");
break;
}
}
}
if (count_s1==0&&count<7) {
System.out.println("You win.");
}else if(count_s1>0&&count<7) {
System.out.println("You chickened out.");
}
}
}
}