Advertisement
Guest User

Java FInd the lost number of array

a guest
Jan 28th, 2020
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1. public class Main
  2. {
  3.     public static void main(String[] args) {
  4.         int n = 10;
  5.         int[] array = new int[n];
  6.         for (int i = 0; i < n; i++) { array[i] = i + 1; }
  7.        
  8.         int delnum = (int) (Math.random() * n + 1);
  9.         System.out.println("Удалённое число: " + delnum + "\nМассив: ");
  10.        
  11.         for (int i = 0; i < n; i++)
  12.         {
  13.             if(array[i] != delnum)
  14.             {
  15.                 System.out.println("[" + i + "] = " + array[i]);
  16.             }
  17.         }
  18.        
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement