Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class hagasha
- {
- public static boolean in(int[][]arr, int num){//הפעולה מקבלת מערך דו מימדי ומספר ומחזירה האם המספר נמצא במערך או לא
- for (int i = 0; i < arr.length; i++)
- {
- for(int j = 0 ; j< arr[i].length; j++){
- if(arr[i][j]==(num)){
- return true;
- }
- }
- }
- return false;
- }
- public static void main(String[] args)
- {
- int num=0;
- int counter=0;
- Scanner s=new Scanner(System.in);
- int[][]arr=new int[2][2];
- for (int i = 0; i < arr.length; i++){
- for (int j = 0; j < arr[i].length; j++){
- System.out.println("Enter number");
- arr[i][j]=s.nextInt();
- }
- }
- for (int i = 0; i < arr.length; i++) {
- for (int j = 0; j < arr[i].length; j++) {
- boolean in=in(arr,num);
- if(in==false&&counter<6){
- counter++;
- System.out.println("number: "+ num);
- }
- num++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement