Advertisement
fryc1906

TabliceZadanie2

Nov 18th, 2015
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 KB | None | 0 0
  1. import java.util.Random;
  2.  
  3.  
  4. public class ZadankoTablice2 {
  5.  
  6.     public static void main(String[] args) {
  7.         int []tab = new int[20];
  8.         int []tabIlosc = new int[10];
  9.         Random rand = new Random();
  10.         for(int i=0; i<tab.length; i++){
  11.             tab[i]=rand.nextInt(10)+1;
  12.             tabIlosc[tab[i]-1]+=1;
  13.             System.out.print(tab[i]+" ");
  14.         }
  15.         System.out.print("\nWystąpienia:\n");
  16.         for(int i=0;i<tabIlosc.length;i++){
  17.             System.out.println(i+1+" - "+tabIlosc[i]+" ");
  18.         }
  19.     }
  20.  
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement