Advertisement
BetinaUKTC

Arrays

Jan 9th, 2020
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.20 KB | None | 0 0
  1. BIGGEST ELEMENT
  2. import java.util.ArrayList;
  3. import java.util.Scanner;
  4.  
  5. public class main {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner scan = new Scanner(System.in);
  9.         int [] array = {5,6,78,37,31,45};
  10.          int max = array[0];           
  11.          for(int i = 1; i<array.length; i++){
  12.              if(array[i]>max) {
  13.                  max = array[i];
  14.              }
  15.          }
  16.          System.out.println(max);
  17.     }
  18. }
  19.  
  20. EQUALS ARRAYS
  21. import java.util.ArrayList;
  22. import java.util.Scanner;
  23.  
  24. public class main {
  25.  
  26.     public static void main(String[] args) {
  27.         Scanner scan = new Scanner(System.in);
  28.         boolean equals = false;
  29.         while (true) {
  30.             String[] a = scan.nextLine().split(" ");
  31.             String[] b = scan.nextLine().split(" ");
  32.             if (a.length != b.length) {
  33.                 System.out.println("not equals");
  34.                 break;
  35.             }
  36.             if (a.length == b.length) {
  37.                 for (int i = 0; i < a.length; i++) {
  38.                     int a1 = Integer.parseInt(a[i]);
  39.                     int b1 = Integer.parseInt(b[i]);
  40.                     if (a1 == b1) {
  41.                         equals = true;
  42.                         continue;
  43.                     } else if (a1 != b1) {
  44.                         equals = false;
  45.                     }
  46.                 }
  47.                 if (equals == true) {
  48.                     System.out.println("equals");
  49.                 } else if (equals != true) {
  50.                     System.out.println("not equals");
  51.                 }
  52.  
  53.             }
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement