Advertisement
Alex_Zuev

Untitled

Feb 26th, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.46 KB | None | 0 0
  1. Enter your code herepackage com.company;
  2. import java.util.Arrays;
  3.  
  4. /**
  5.  * Created by Alex on 26.02.2015.
  6.  */
  7. public class Massive {
  8.     public static boolean Check(int a) {
  9.         if (a % 2 == 0 && a != 0) {
  10.             return true;
  11.         } else return false;
  12.     }
  13.  
  14.  
  15.     public static void main(String[] args) {
  16.         int m[] = new int[5];
  17.         double mSumm=0;
  18.         int m1[] = new int[5];
  19.         double m1Summ=0;
  20.         int count = 0;
  21.         for (int i = 0; i < 5; i++) {
  22.             m[i] = ((int) (Math.random() * 5));
  23.             mSumm=mSumm+ m[i];
  24.         }
  25.         for (int i = 0; i < m.length; i++) {
  26.             System.out.print(m[i] + " ");
  27.         }
  28.         mSumm=mSumm/m.length;
  29.         System.out.println("Среднеарифметическое ="+mSumm);
  30.  
  31.         for (int i = 0; i < 5; i++) {
  32.             m1[i] = ((int) (Math.random() * 5));
  33.             m1Summ=m1Summ+ m1[i];
  34.         }
  35.         for (int i = 0; i < m1.length; i++) {
  36.             System.out.print(m1[i] + " ");
  37.             }
  38.         m1Summ =m1Summ/m1.length;
  39.         System.out.println("Среднеарифметическое ="+m1Summ);
  40.        
  41.         if(mSumm > m1Summ)
  42.                 System.out.println("Первый массив больше");
  43.         else if (mSumm == m1Summ)
  44.                 System.out.println("Сумма элементов обоих массивов равна");
  45.         else
  46.                 System.out.println("Второй массив больше");
  47.     }
  48.  
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement