Advertisement
Talar97

Kolokwium Z2 (1/1pkt)

Dec 11th, 2017
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. package com.Talar;
  2.  
  3. import java.util.Random;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.         Random rand = new Random();
  9.         int tab[][] = new int[10][10];
  10.         int r1 = 0;
  11.         int suma = 0;
  12.         int srednia[] = new int[10];
  13.  
  14.         for(int i = 0; i < 10; i++){
  15.             for(int j = 0; j < 10; j++){
  16.                 r1 = rand.nextInt(100);
  17.                 tab[i][j] = r1;
  18.                 //System.out.print(tab[i][j] + ", ");
  19.             }
  20.             //System.out.print("\n");
  21.         }
  22.  
  23.         for(int k = 0; k < 10; k++){
  24.             for(int l = 0; l < 10; l++){
  25.                 suma += tab[l][k];
  26.             }
  27.             srednia[k] = suma/10;
  28.             System.out.println("Średnia dla " + (k+1) + " kolumny: " + srednia[k]);
  29.             suma = 0;
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement