import java.io.*;public class CountChar { public static void main(String[] args) throws IOException { String ch; BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter the Statement:"); ch=br.readLine(); int count=0,len=0; do { try { char name[]=ch.toCharArray(); len=name.length; count=0; for(int j=0;j<len;j++) { if((name[0]==name[j])&&((name[0]>=65&&name[0]<=91)||(name[0]>=97&&name[0]<=123))) count++; } if(count!=0) System.out.println(name[0]+" "+count+" Times"); ch=ch.replace(""+name[0],""); } catch(Exception ex){} } while(len!=1); }}
输出量
Enter the Statement:asdf23123sfsdfa 1 Timess 3 Timesd 2 Timesf 3 Times
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)