解题思路:
注意事项:
eclipse上运行无错,答案正确,但是在题目下运行显示运行错误所以本答案仅供参考
参考代码:
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Scanner;
class Student{
int Num;
int Grade;
public int getNum() {
return Num;
}
public void setNum(int num) {
Num = num;
}
public int getGrade() {
return Grade;
}
public void setGrade(int grade) {
Grade = grade;
}
public Student(int num, int grade) {
super();
Num = num;
Grade = grade;
}
public String toString() {
return this.Num+" "+ this.Grade;
}
public int hashCode(){
return this.Num;
}
}
public class Main{
public static void Link(int N,int M){
Scanner sc = new Scanner(System.in);
LinkedList<Student> listA = new LinkedList<>();
for(int i=0;i<N;i++){
listA.add(new Student(sc.nextInt(),sc.nextInt()));
}
LinkedList<Student> listB = new LinkedList<>();
for(int i=0;i<M;i++){
listB.add(new Student(sc.nextInt(),sc.nextInt()));
}
listA.addAll(listB);
HashSet<Student> hs = new HashSet<>(listA);
Iterator it = hs.iterator();
while(it.hasNext()){
System.out.print(it.next()+"\n");
}
}
public static void main(String[] arg){
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();
Link(N,M);
}
}
0.0分
1 人评分
点我有惊喜!你懂得!浏览:4074 |
C语言程序设计教程(第三版)课后习题11.3 (C语言代码)浏览:1057 |
C语言程序设计教程(第三版)课后习题8.9 (C语言代码)浏览:690 |
简单的a+b (C语言代码)浏览:581 |
C语言程序设计教程(第三版)课后习题6.3 (C语言代码)浏览:552 |
C语言程序设计教程(第三版)课后习题7.1 (C语言代码)浏览:1265 |
WU-蓝桥杯算法提高VIP-企业奖金发放 (C++代码)浏览:1246 |
C语言程序设计教程(第三版)课后习题6.11 (C语言代码)浏览:562 |
DNA (C语言描述,蓝桥杯)浏览:1648 |
分糖果 (C语言代码)浏览:979 |