输入一个长度
,仅由图片中的可见字符构成的字符串
。
在一行上输出一个整数,代表给定字符串中 ASCII 码在
到
范围内的不同字符的个数。
[@A8aA].0
8
import java.util.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String str = in.next();
int len = str.length();
Set<Character> set = new HashSet<>();
for(int i= 0;i< len; i++){
int c = str.charAt(i);
char c1 = str.charAt(i);
if(c>= 33 && c<= 126 && !set.contains(c1)){
set.add(c1);
}
}
System.out.println(set.size());
}
} public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String str = in.next();
Set set = new HashSet();
for(int i=0;i<str.length();i++){
int asc = (int)str.charAt(i);
if(asc >127 || asc <0){
continue;
}
set.add(str.charAt(i));
}
System.out.println(set.size());
} import java.util.Scanner;
import java.util.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
String str = in.nextLine();
Set<Integer> num = new HashSet<>();
for (int i = 0; i < str.length(); i++) {
num.add((int)str.charAt(i));
}
System.out.println(num.size());
}
} import java.util.Scanner;
import java.util.LinkedHashSet;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别 // 注意 while 处理多个 case
String a = in.nextLine();
LinkedHashSetInteger> set = new LinkedHashSet();
for(int i=0;ia.length();i++){
int b = (int)a.charAt(i);
if(b>=0&&b127){
set.add(b);
}
}
System.out.print(set.size());
} }
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
String str = in.nextLine();
int count =0;zz
Set s = new HashSet<Character>();
for(int i =0; i< str.length();i++){
Character c = str.charAt(i);
try{
int a = c;
if(a >=0 && a<=127){
s.add(a);
}
}catch(Exception e){
continue;
}
}
System.out.println(s.size());
}
} import java.util.*; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String str=in.nextLine(); //set容器不允许有重复的元素,所以用set容器存储字符 HashSet<Character> set= new HashSet<Character>(); for(int i=0;i<str.length();i++){ if(str.charAt(i)>=0 && str.charAt(i)<=127){ set.add(str.charAt(i)); } } System.out.println(set.size()); } }
import java.util.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String str = in.nextLine();
//使用HashSet存储不同的字符
Set<Character> chars = new HashSet<>();
for (int i = 0; i < str.length(); i++) {
// 将字符添加到HashSet中,自动去重
chars.add(str.charAt(i));
}
System.out.println(chars.size());
}
} import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
List<Character> list = new ArrayList<>();
String str = in.nextLine();
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
if (!list.contains(c)) {
list.add(c);
}
}
System.out.println(list.size());
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String str = in.nextLine();
System.out.println(str.chars().distinct().count());
}
}