Files
  • Main.java
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
class Main {
  public static void main(String[] args) {
    int arr1[] = new int[10];
    int c,x;
    System.out.println("First list");
    System.out.println("Original numbers: ");
    for(x = 0; x < 10; x++){
      arr1[x] = (int) (40 * Math.random() + 1);
      System.out.print(arr1[x] + " ");
    }

    for(c = 0; c< (x - 1); c++){
      for(int d = 0; d < x - c - 1; d++){
        if(arr1[d] > arr1[d+1]){
          int swap = arr1[d];
          arr1[d] = arr1[d+1];
          arr1[d+1] = swap;
          }
        }
      }
    System.out.println("");
    System.out.println("Sorted numbers: ");
    for(c = 0; c < 10; c++){
      System.out.print(arr1[c] + " ");
    }

    int arr2[] = new int[10];
    int c2,x2;
    System.out.println("");
    System.out.println("");
    System.out.println("Second list");
    System.out.println("Original numbers: ");
    for(x2 = 0; x2 < 10; x2++){
      arr2[x2] = (int) (40 * Math.random() + 1);
      System.out.print(arr2[x2] + " ");
    }

    for(c2 = 0; c2< (x2 - 1); c2++){
      for(int d2 = 0; d2 < x2 - c2 - 1; d2++){
        if(arr2[d2] > arr2[d2+1]){
          int swap2 = arr2[d2];
          arr2[d2] = arr2[d2+1];
          arr2[d2+1] = swap2;
          }
        }
      }
    System.out.println("");
    System.out.println("Sorted numbers: ");
    for(c2 = 0; c2 < 10; c2++){
      System.out.print(arr2[c2] + " ");
    }

    System.out.printf("%n");
    System.out.printf("%n");
    System.out.println("Array3: ");
    int arr3[]=new int[10];
    for(int r  = 0; r <= 9; r++){
      arr3[r] = arr1[r] + arr2[r];
      System.out.print(arr3[r] + " ");
    }
  }
}