Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Enter your code herepublic class Massive {
- public static void main(String[] args) {
- int m[] = new int[11];
- int a1 = 0;
- int a2 = 0;
- int a3 = 0;
- for (int i = 0; i < m.length; i++) {
- m[i] = ((int) ((Math.random() * 4) - 2));
- if (m[i] == 1)
- a1++;
- else if (m[i] == 0)
- a2++;
- else a3++;
- }
- for (int i = 0; i < m.length; i++) {
- System.out.print(m[i] + " ");
- }
- System.out.println();
- if (a1 > a2 && a1 > a3)
- System.out.println("1 = " + a1);
- else if (a2 > a1 && a2 > a3)
- System.out.println("0 = " + a2);
- else if (a3 > a1 && a3 > a2)
- System.out.println("-1 = " + a3);
- else System.out.println(" нет доминирующего значения");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement