题目描述:
输入一个int型整数,按照从右向左的阅读顺序,返回一个不含重复数字的新的整数。
输入例子:
9876673
输出:
37689
public static void SelectInt(int a) {
Set<Integer> set = new LinkedHashSet<Integer>();
while (a != 0) {
set.add(a % 10);
a = a / 10;
}
for (Integer integer : set) {
System.out.print(integer);
}
}
题目描述:
编写一个函数,计算字符串中含有的不同字符的个数。字符在ACSII码范围内(0~127)。不在范围内的不作统计。
输入例子:
abc
输出例子:
3
public static void NumOfASCII(String a) {
char[] c = a.toCharArray();
Set<Character>set=new LinkedHashSet<Character>();
for(int i=0;i<c.length;i++){
set.add(c[i]);
}
System.out.println(set.size());
}