Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Enter your code herepackage com.company;
- import java.util.Arrays;
- import java.util.Scanner;
- /**
- * Created by Alex on 26.02.2015.
- */
- public class Massive {
- public static boolean Check (double a){
- if (a>0 && a%2==0)
- return true;
- else return false;
- }
- public static void main(String[] args) {
- int a=0;
- for (int i=0;i<1;) {
- Scanner sc = new Scanner(System.in);
- System.out.println("введите чётное положительное число: ");
- a = sc.nextInt();
- if (Check(a)==true)
- i++;
- }
- int b=(int)a;
- int m[] = new int[b];
- for (int i = 0; i < m.length; i++) {
- m[i] = ((int) ((Math.random() * 11)-5.6 ));
- }
- int half1=0;
- int half2=0;
- for (int i = 0; i < m.length; i++) {
- System.out.print(m[i] + " ");
- if (i<m.length/2)
- half1=half1+Math.abs(m[i]);
- else half2=half2+Math.abs(m[i]);
- }
- System.out.println();
- if (half1>half2)
- System.out.println("Sum modules of 1st half massive are Lager");
- else if (half2>half1)
- System.out.println("Sum modules of 2nd half massive are Lager");
- else
- System.out.println("Sum's modules of 1st and 2nd half's massive are equally");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement