package homework;
import java.io.*;
public class Topic6 {
public static void main(String[] args) throws IOException{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int num=0;
int[] alpha = new int[26];
char[] ch=null;
System.out.print("How many character do you want to get(only lower case)? : ");
num = Integer.parseInt(in.readLine());
ch = new char[num];
System.out.print("Characters : ");
for(int i=0;i<ch.length;i++){
ch[i]=(char)System.in.read();
}
for(int i=0;i<ch.length;i++)
alpha[ch[i]-65]++;
for(int i=1;i<=alpha.length;i++){
System.out.print((char)(i+64)+"="+alpha[i-1]+" ");
if(i % 3== 0)
System.out.println();
}
}
}
No comments:
Post a Comment