Advertisement
Guest User

Zadanie3bpjatk

a guest
Nov 17th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. package PPJcwiczenia.Zadania8;
  2.  
  3. public class Zadanie3b {
  4.  
  5. // TAK JAK MA BYC
  6.  
  7. public static void main(String[] args) {
  8.  
  9. char[] tab = "Ala ma kota.".toCharArray();
  10.  
  11. licznik(tab);
  12. }
  13.  
  14.  
  15. public static void licznik(char[] tab) {
  16. int[] tab2 = new int[128];
  17.  
  18. for ( int i = 0 ; i < tab.length ; i++)
  19. {
  20. tab2[tab[i]]++;
  21.  
  22. }
  23.  
  24. for (int i = 0 ; i < tab2.length ; i++){
  25. if (tab2[i]!=0){
  26. System.out.println((char)i +":"+tab2[i]);
  27. }
  28. }
  29.  
  30.  
  31.  
  32.  
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement