标签:
class student { String name; String sno; String sex; public student(String name,String sno,String sex){ this.name=name; this.sno=sno; this.sex=sex; } }
import java.util.Scanner; public class Main { static student stu[]; public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc=new Scanner(System.in); while(sc.hasNext()){ int n=sc.nextInt(); stu=new student[n]; for(int i=0;i<n;i++){ String name=sc.next(); String sno=sc.next(); String sex=sc.next(); stu[i]=new student(name,sno,sex); } int t=sc.nextInt(); while(t-->0){ String tmp=sc.next(); String tmp2=sc.next(); String Sex1=""; String Sex2=""; for(int i=0;i<n;i++){ if(stu[i].name.equals(tmp)||stu[i].sno.equals(tmp)) { Sex1=stu[i].sex; } if(stu[i].name.equals(tmp2)||stu[i].sno.equals(tmp2)) { Sex2=stu[i].sex; } } if(!Sex1.equals(Sex2)) System.out.println("Y"); else System.out.println("N"); } } sc.close(); } }
标签:
原文地址:http://www.cnblogs.com/watchfree/p/5347009.html