Advertisement
DanikYakush

Task20

Jul 5th, 2022
767
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. import java.util.Random;
  2. import java.util.Scanner;
  3.  
  4. public class task20 {
  5.     public static void main(String[] args) {
  6.         int n, k;
  7.         int counter1 = 0;
  8.         int counter2 = 0;
  9.         int counter3 = 0;
  10.         Random rand = new Random();
  11.         Scanner in = new Scanner(System.in);
  12.         n = in.nextInt();
  13.         k = in.nextInt();
  14.         int[] array = new int[n];
  15.         for (int i = 0; i < n; i++) {
  16.             array[i] = rand.nextInt(-100, 100);
  17.             if (array[i] > 0) counter1++;
  18.             if (array[i] < 0) counter2++;
  19.             else counter3++;
  20.         }
  21.         System.out.println(counter1 + " " + counter2 + " " + counter3);
  22.     }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement