Advertisement
Alex_Zuev

Untitled

Feb 27th, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.37 KB | None | 0 0
  1. Enter your code herepackage com.company;
  2. import java.util.Arrays;
  3. import java.util.Scanner;
  4. /**
  5.  * Created by Alex on 26.02.2015.
  6.  */
  7. public class Massive {
  8.  
  9.     public static boolean Check (double a){
  10.         if (a>0 && a%2==0)
  11.             return true;
  12.         else return false;
  13.     }
  14.  
  15.     public static void main(String[] args) {
  16.         int a=0;
  17.         for (int i=0;i<1;) {
  18.  
  19.  
  20.             Scanner sc = new Scanner(System.in);
  21.  
  22.             System.out.println("введите чётное положительное число: ");
  23.             a = sc.nextInt();
  24.             if (Check(a)==true)
  25.                 i++;
  26.         }
  27.         int b=(int)a;
  28.         int m[] = new int[b];
  29.         for (int i = 0; i < m.length; i++) {
  30.             m[i] = ((int) ((Math.random() * 11)-5.6  ));
  31.  
  32.         }
  33.         int half1=0;
  34.         int half2=0;
  35.         for (int i = 0; i < m.length; i++) {
  36.             System.out.print(m[i] + " ");
  37.             if (i<m.length/2)
  38.                 half1=half1+Math.abs(m[i]);
  39.             else half2=half2+Math.abs(m[i]);
  40.         }
  41.         System.out.println();
  42.         if (half1>half2)
  43.             System.out.println("Sum modules of 1st half massive are Lager");
  44.         else if (half2>half1)
  45.             System.out.println("Sum modules of 2nd half massive are Lager");
  46.         else
  47.             System.out.println("Sum's modules of 1st and 2nd half's massive are equally");
  48.  
  49.     }
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement