Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package lab3;
- /**
- *
- * @author user
- */
- public class Lab3 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- Przykl1 przyklad1 = new Przykl1();
- Przykl2 przyklad2 = new Przykl2();
- }
- }
- class Przykl1
- {
- public Przykl1()
- {
- 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 Przykl2
- {
- public Przykl2()
- {
- 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