查找一字符串中只出现一次的第一个字符
import java.util.Scanner;
class Main {
static int n1 = 0;
public static class s {
int num = 0;
int n = 0;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
int n2 = 128;
int j = 0;// 记录结果位置
int n3;
char a;
s[] array = new s[128];
for (int i = 0; i < array.length; i++) {
array[i] = new s();
}
for (int i = 0; i < s.length(); i++) {
a = s.charAt(i);
n3 = a - '\0';
if (array[n3].num == 0)
array[n3].n = ++n1;
array[n3].num++;
}
for (int i = 0; i < array.length; i++) {
if (array[i].num == 1 && array[i].n < n2) {
n2 = array[i].n;
j = i;
}
}
System.out.println((char) (j - '\0'));
}
}