Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package v;
- import java.util.Random;
- /**
- *
- * @author Użytkownik
- */
- class A
- {
- int [][] tab;
- Random r;
- A(int x, int y)
- {
- tab=new int [x][y];
- r=new Random();
- }
- void PrintTab()
- {
- for(int i=0;i<tab.length;i++)
- {
- System.out.println("");
- for(int j=0;j<tab[i].length;j++)
- System.out.print(tab[i][j]+" ");
- }
- }
- void RandomFill()
- {
- for(int v=0;v<tab.length;v++)
- {
- for(int x=0;x<tab[v].length;x++)
- tab[v][x]=r.nextInt(10);
- }
- }
- void Wypisz()
- {
- for(int v=0;v<tab.length;v++)
- {
- for(int x=0;x<tab[v].length;x++)
- {
- if (x<3)
- tab[v][x]=1;
- if (x>=3)
- tab[v][x]=2;
- if (x>tab.length-4)
- tab[v][x]=1;
- }
- }
- }
- }
- public class V {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- A x=null;
- x=new A(15,15);
- x.RandomFill();
- x.Wypisz();
- x.PrintTab();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement