-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudents Report.txt
More file actions
47 lines (39 loc) · 825 Bytes
/
Students Report.txt
File metadata and controls
47 lines (39 loc) · 825 Bytes
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
import java.util.*;
import java.lang.*;
import java.io.*;
// The main method must be in a class named "Main".
class Main {
public static void func(int[][] arr){
int minIndex=0;
int minSum=Integer.MAX_VALUE;
for(int j=0;j<arr[0].length;j++){
int sum=0;
for(int i=0;i<arr.length;i++){
sum+=arr[i][j];
}
if(sum<minSum){
minSum=sum;
minIndex=j;
}
}
int[] res=new int[arr.length];
for(int i=0;i<arr.length;i++){
int val=0;
for(int j=0;j<arr[0].length;j++){
if(j==minIndex){
continue;
}else{
val+=arr[i][j];
}
}
res[i]=val;
}
for(int i=0;i<res.length;i++){
System.out.print(res[i] + " ");
}
}
public static void main(String[] args) {
int[][] arr={{75,76,65,87,87},{78,76,68,56,89},{67,87,78,77,65}};
func(arr);
}
}