Advertisement
KaczakKwaczak

Laby3

Nov 22nd, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.78 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package lab;
  7.  
  8. /**
  9.  *
  10.  * @author Ulachy
  11.  */
  12. public class labki {
  13.  
  14.     /**
  15.      * @param args the command line arguments
  16.      */
  17.     public static void main(String[] args) {
  18.     program1 program1 = new program1();
  19.     System.out.println("********************");
  20.     program2 program2 = new program2();// TODO code application logic here
  21.     }
  22.    
  23. }
  24.  
  25. class program1{
  26.     public program1()
  27.     {
  28.         int x,y;
  29.         int[][]a = { { 1, 2 }, { 3, 4 } };
  30.         int b[][] = { { 1, 2 }, { 3 }, {} };
  31.         a[0][0] = 0;
  32.         x = a[1][1];
  33.         System.out.println("Wartość elementu o indeksach 1,1 tablicy a to "+x);
  34.         y = b.length;
  35.         System.out.println("Rozmiar tablicy b to "+y);
  36.         y = b[0].length;
  37.         System.out.println("Rozmiar pierwszego wiersza tablicy b to "+y);
  38.         y = b[1].length;
  39.         System.out.println("Rozmiar drugiego wiersza tablicy b to "+y);
  40.         y = b[2].length;
  41.         System.out.println("Rozmiar trzeciego wiersza tablicy b to "+y);
  42.     }
  43. }
  44.  
  45. class program2{
  46.     public program2()
  47.     {
  48.         int tab[][] = new int [5][];
  49.         tab[0] = new int[4];
  50.         tab[1] = new int[3];
  51.         tab[2] = new int[2];
  52.         tab[3] = new int[1];
  53.         tab[4] = new int[4];
  54.         int i,j;
  55.         for (i=0;i<tab.length;i++)
  56.         {
  57.             for(j=0;j<tab[i].length;j++)
  58.             tab[i][j]=(int)(100*Math.random());}
  59.         for (i=0;i<tab.length;i++)
  60.         {
  61.             for(j=0;j<tab[i].length;j++)
  62.             System.out.print(tab[i][j]+"\t");
  63.             System.out.println();
  64.            
  65.         }
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement