Advertisement
DanikYakush

Task19

Jul 5th, 2022
685
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None
  1. import java.util.Random;
  2. import java.util.Scanner;
  3.  
  4. public class Task19 {
  5.     public static void main(String[] args) {
  6.         int n, k;
  7.         int counter = 1;
  8.         Random rand = new Random();
  9.         Scanner in = new Scanner(System.in);
  10.         n = in.nextInt();
  11.         k = in.nextInt();
  12.         int[] array = new int[n];
  13.         for (int i = 0; i < n; i++) {
  14.             array[i] = rand.nextInt(1, 100);
  15.             if(array[i] > k){
  16.                 array[i] = k;
  17.                 counter++;
  18.             }
  19.         }
  20.         System.out.println(counter);
  21.     }
  22. }
  23.  
Advertisement
RAW Paste Data Copied
Advertisement