Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ss;
- import java.util.Random;
- import java.util.Scanner;
- public class ss {
- public static void main(String[] args) {
- // TODO Auto-genera;ted method stub
- int[][] tab = new int [5][5];
- int x,n;
- x=0;
- n=0;
- Scanner odczyt = new Scanner(System.in);
- System.out.print("Podaj liczbe:");
- x = odczyt.nextInt();
- Random losuj = new Random();
- for(int i=0;i<5;i++) {
- for(int j=0;j<5;j++){
- tab[i][j]= losuj.nextInt(50);
- }
- }
- for(int i=0;i<5;i++){
- for(int j=0;j<5;j++)
- {
- if(x==tab[i][j])
- {
- n++;
- }
- }
- }
- System.out.println("Wylosowana tablica:");
- for(int i=0;i<5;i++){
- for(int j=0;j<5;j++){
- System.out.print(" ["+tab[i][j]+"]");
- if( j==4){
- System.out.println(" ["+tab[i][j]+"]");
- }
- }
- }
- System.out.println("");
- System.out.println("Trafiles "+n);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement