[java]代码库import java.util.*;
public class Main{
public static void main(String[] args ) {
Scanner scan = new Scanner(System.in);
int num, no, score, i, j;
String name, op;
num = scan.nextInt();
Map map = new HashMap();
Student s;
for(i = 0; i < num; i++) {
no = scan.nextInt();
name = scan.next();
score = scan.nextInt();
s = new Student(no, name, score);
map.put(no, s);
}
num = scan.nextInt();
for(j = 0; j < num; j++) {
op = scan.next();
if(op.equals("add")){
no = scan.nextInt();
name = scan.next();
score = scan.nextInt();
s = new Student(no, name, score);
map.put(no, s);
}
else if(op.equals("delete")) {
no = scan.nextInt();
map.remove(no);
}
else if(op.equals("set")) {
no = scan.nextInt();
score = scan.nextInt();
map.get(no).setScore(score);
}
}
Iterator> iter = map.entrySet().iterator();
while(iter.hasNext()) {
Map.Entry entry = iter.next();
System.out.println(entry.getValue());
}
scan.close();
}
}
class Student{
int no;
String name;
int score;
public Student(int _no, String _name, int _score) {
no = _no;
name = _name;
score = _score;
}
public int getNo() {
return no;
}
public String getName() {
return name;
}
public int getScore() {
return score;
}
public void setScore(int sc) {
score = sc;
}
public String toString() {
return "no:" +no +" name:" +name +" score:" +score;
}
public boolean equals(Student s) {
if(this.no==s.getNo() && this.name.equals(s.getName()) && this.score==s.getScore())
return true;
else
return false;
}
public int hashcode() {
int result = 17;
result = 31*result + no;
return result;
}
}