java写~~~
谢谢啦~~~~
Description
给定一系列整型数据,删除其中重复的数据使各种数据仅保留一份。
Input
输入数据有多行,每行有若干个整数,每行总字符数不超过65536字节。为简化编程,这里的整数都在整型范围中。
Output
输入数据有多行,每行有若干个整数,每行总字符数不超过65536字节。为简化编程,这里的整数都在整型范围中。
对于每一种情形,输出处理结果,换行。注意:按输入顺序输出序列,使得后面出现的相同数字被删除。
Sample Input
86 75 90 78 78 93 88 80 86 78
78 85 83 81 85 76 76 92
Sample Output
86 75 90 78 93 88 80
78 85 83 81 76 92
------解决思路----------------------
Scanner in = new Scanner(System.in);
while (in.hasNextLine()) {
Set<Integer> set = new LinkedHashSet<Integer>();
for (String s : in.nextLine().split(" ")) {
set.add(Integer.parseInt(s));
}
for (int i : set) {
System.out.print(i + " ");
}
System.out.println();
}