L1-030 一帮一-java

L1-030 一帮一-java_第1张图片

输入样例:

8
0 Amy
1 Tom
1 Bill
0 Cindy
0 Maya
1 John
1 Jack
0 Linda

输出样例:

Amy Jack
Tom Linda
Bill Maya
Cindy John

 



import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
public static void main(String[] args) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	int n = Integer.parseInt(br.readLine());
	 String[][] strings = new String[n][3];
	for(int i=0;i0;j--) {
			if(!strings[i][0].equals(strings[j][0])) {
				if(strings[i][2].equals("true")&&strings[j][2].equals("true")) {
					strings[i][2]="false";
					strings[j][2]="false";
					System.out.println(strings[i][1]+" "+ strings[j][1]);
					break;
				}
	
			}
		}
	}
}
}

 

你可能感兴趣的:(pta,java,python,开发语言)