# C~K要找女朋友了！！！

Problem Description

ps:由于MeiK比较傻，所以名单里可能会有重复的女生的信息，若信息重复，则第一次输入为有效信息。

Input

ps：联系方式不超过11个字符。

Output

Sample Input
4
160 170 20 22

Sample Output
2

package pp;

import java.util.*;

class Person{
String name, tel;
int height, age;
public Person(String name, int height, int age, String tel) {
super();
this.name = name;
this.height = height;
this.age = age;
this.tel = tel;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + age;
result = prime * result + height;
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((tel == null) ? 0 : tel.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Person other = (Person) obj;
if (age != other.age)
return false;
if (height != other.height)
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
if (tel == null) {
if (other.tel != null)
return false;
} else if (!tel.equals(other.tel))
return false;
return true;
}

public String toString() {//按照实例输出
return name + " " + height + " " + age + " " + tel;
}

}

public class Main {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()) {
int n = sc.nextInt();//几个人
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int d = sc.nextInt();
List<Person>  list = new ArrayList<Person>();

while(n-- != 0) {
String name = sc.next();
int height = sc.nextInt();
int age = sc.nextInt();
String tel = sc.next();
if(age >= c && age <= d && height >= a && height <= b) {
Person p = new Person(name, height, age, tel);
if(!list.contains(p))//是否已经有相同的
{
}
}
}
Collections.sort(list, new Comparator<Person>(){//匿名内部类进行排序
public int compare(Person o1, Person o2){
if(o1.height == o2.height){
return o2.age - o1.age;//年龄从高到低输出
}

return o1.height - o2.height;//身高从低到高输出
}
});
System.out.println(list.size());//个数
Iterator<Person> it = list.iterator();
while(it.hasNext()) {
System.out.println(it.next());
}

}
sc.close();
}
}


• 广告
• 抄袭
• 版权
• 政治
• 色情
• 无意义
• 其他

120