Advertisement
Alex_Zuev

Untitled

Feb 27th, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 0 0
  1. Enter your code herepublic class Massive {
  2.  
  3.     public static void main(String[] args) {
  4.         int m[] = new int[11];
  5.         int a1 = 0;
  6.         int a2 = 0;
  7.         int a3 = 0;
  8.         for (int i = 0; i < m.length; i++) {
  9.             m[i] = ((int) ((Math.random() * 4) - 2));
  10.             if (m[i] == 1)
  11.                 a1++;
  12.             else if (m[i] == 0)
  13.                 a2++;
  14.             else a3++;
  15.         }
  16.         for (int i = 0; i < m.length; i++) {
  17.             System.out.print(m[i] + " ");
  18.         }
  19.         System.out.println();
  20.         if (a1 > a2 && a1 > a3)
  21.             System.out.println("1 = " + a1);
  22.         else if (a2 > a1 && a2 > a3)
  23.             System.out.println("0 = " + a2);
  24.         else if (a3 > a1 && a3 > a2)
  25.             System.out.println("-1 = " + a3);
  26.         else System.out.println(" нет доминирующего значения");
  27.     }
  28.  
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement