Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package lab;
- /**
- *
- * @author Ulachy
- */
- public class labki {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- program1 program1 = new program1();
- System.out.println("********************");
- program2 program2 = new program2();// TODO code application logic here
- }
- }
- class program1{
- public program1()
- {
- int x,y;
- int[][]a = { { 1, 2 }, { 3, 4 } };
- int b[][] = { { 1, 2 }, { 3 }, {} };
- a[0][0] = 0;
- x = a[1][1];
- System.out.println("Wartość elementu o indeksach 1,1 tablicy a to "+x);
- y = b.length;
- System.out.println("Rozmiar tablicy b to "+y);
- y = b[0].length;
- System.out.println("Rozmiar pierwszego wiersza tablicy b to "+y);
- y = b[1].length;
- System.out.println("Rozmiar drugiego wiersza tablicy b to "+y);
- y = b[2].length;
- System.out.println("Rozmiar trzeciego wiersza tablicy b to "+y);
- }
- }
- class program2{
- public program2()
- {
- int tab[][] = new int [5][];
- tab[0] = new int[4];
- tab[1] = new int[3];
- tab[2] = new int[2];
- tab[3] = new int[1];
- tab[4] = new int[4];
- int i,j;
- for (i=0;i<tab.length;i++)
- {
- for(j=0;j<tab[i].length;j++)
- tab[i][j]=(int)(100*Math.random());}
- for (i=0;i<tab.length;i++)
- {
- for(j=0;j<tab[i].length;j++)
- System.out.print(tab[i][j]+"\t");
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement