-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab2.java
More file actions
45 lines (42 loc) · 1.39 KB
/
Lab2.java
File metadata and controls
45 lines (42 loc) · 1.39 KB
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
package com.company;
import java.util.Scanner;
/**
* C5 = 3, C=A⊕B;
* C7 = 4, long;
* C11 = 3: Обчислити суму найбільших елементів кожного стовпця матриці
*/
public class Lab2 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter size of the array");
int s = in.nextInt();
long[][] a = new long[s][s];
long[][] b = new long[s][s];
long[][] c = new long[s][s];
int Res = 0;
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a.length; j++) {
a[i][j] = (long) Math.round(Math.random() * 10);
b[i][j] = (long) Math.round(Math.random() * 10);
c[i][j] = (clonghar) (a[i][j] ^ b[i][j]);
}
}
for (long[] ints : c) {
for (long anInt : ints) {
System.out.print((int)anInt + "\t");
}
System.out.println();
}
long cmax;
for (int i = 0; i < c[0].length; i++) {
cmax = 0;
for(int j = 0; j < c.length; j++) {
if (c[j][i] > cmax) {
cmax = c[j][i];
}
}
Res += cmax;
}
System.out.println("The result is " + Res);
}
}