Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String args[]) {
- int[] a = {44, 33, 4, 100, 20, 10};
- int max = a[0];
- int min = a[0];
- int maxIndex = 0;
- for (int i = 1; i < a.length; i++) {
- if (a[i] > max) {
- max = a[i];
- maxIndex = i;
- }else if (a[i] < min) {
- min = a[i];
- }
- }
- System.out.println("Didziausias massive elementas:" + max);
- System.out.println("Maziausias massive elementas:" + min);
- int[] b = {5, 6, 10, 15, 8, 4};
- int[] c = {8, 5, 3};
- int sumaB = 0;
- int sumaC = 0;
- double averageB;
- double averageC;
- double changer;
- for (int i = 0; i < b.length; i++) {
- sumaB += b[i];
- }
- for (int i = 0; i < c.length; i++) {
- sumaC += c[i];
- }
- averageB = (double)sumaB / (double)b.length;
- averageC = (double)sumaC / (double)c.length;
- changer = averageB - averageC;
- System.out.println("massive B average:" + averageB);
- System.out.println("massive C average:" + averageC);
- System.out.println("massive changer:" + changer);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement