public class AlphabetFrequencyString { static int i,j,k,c=0,w; static char m; //we can only define static for variables and fns not for arrays public static void main(String[] args) { Scanner obj = new Scanner(System.in);
String s1=obj.nextLine(); frequencycount(s1); } static void frequencycount(String s) { char[] z=new char[s.length()]; for(w=0;w<s.length();w++) z[w]=s.charAt(w); for(i=0;i<w;i++) { char ch=z[i]; for(j=i+1;j<w;j++) { if(z[j]==ch) { for(k=j;k<(w-1);k++) z[k]=z[k+1]; w--; j=i; } } } int[] t=new int[w]; for(i=0;i<w;i++) { for(j=0,c=0;j<s.length();j++) { if(z[i]==s.charAt(j)) c++; } t[i]=c ; System.out.print(z[i]+"="+c+","); } } }
9
ReplyDelete98
876
7654
65432
543210
sir i need this pattran answer
Sorry for late Reply
DeletePlease Send me email id
This comment has been removed by the author.
ReplyDeletethanks
Delete