package stringPaixu;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Text1
{
public static void main(String[] args)throws Exception
{
char ch = ' ';
int count = 0;
char[] ss;
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
String str = null;
while((str=bf.readLine()) != null){
String weiyi ="";
ss = str.toCharArray();
for (int x = 0; x < ss.length; x++) {
ch = ss[x];
if (weiyi.contains(ch + "")) {
continue;
}
count = find(ss, ch);
weiyi += (ch + "");
System.out.print(ch + "(" + count + ") ");
}
}
bf.close();
}
public static int find(char[] ss, char ch){
int count=0;
for(int x=0; x<ss.length; x++){
if(ch==ss[x]){
count++;
}
}
return count;
}
}
数组法:lol
|