package com.heima.test1;
import java.util.Scanner;
import java.util.TreeSet;
public class Test05 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("请输入字符串:(格式类似12 78 34 56 67 45 23 89)");
String s=sc.nextLine();
String[] arr=s.split(" ");
for (int i = 0; i < arr.length; i++) {
if(arr[i].contains("6")){
arr[i]=arr[i].replaceAll("6", "9");
}
}
TreeSet<Integer> ts=new TreeSet<>();
for (String str : arr) {
ts.add(Integer.parseInt(str));
}
for (Integer in : ts) {
System.out.print(in+" ");
}
}
}
|