fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Scanner sc = new Scanner(System.in);
  13. String s = sc.nextLine();
  14. char[] s1 = s.toLowerCase().toCharArray();
  15. int[] a = new int[4];
  16. for (int i = 0; i < s1.length; i++)
  17. {
  18. a[s1[i] - 'a']++;
  19. }
  20. for (int i = 0; i < 4; i++)
  21. {
  22. System.out.print(String.valueOf((char)('a' + i)) + a[i] + " ");
  23. }
  24. }
  25. }
Success #stdin #stdout 0.13s 321344KB
stdin
aacdbcc
stdout
a2 b1 c3 d1