-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiagnol_sum.java
More file actions
37 lines (28 loc) · 868 Bytes
/
diagnol_sum.java
File metadata and controls
37 lines (28 loc) · 868 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
//import java.util.*;
/*public class diagnol_sum{
public static void Diagnol(int arr[][]){
int psum=0;
int ssum=0;
int ccase=0;
for(int i=0;i<arr.length;i++){
for(int j=0;j<arr[0].length;j++){
if(i==j){
//primary matrix sum
psum=psum+arr[i][j];
}
if(j==arr.length-i){
//secondary sum of the matrix
ssum=ssum+arr[i][j];
}
if(i==j && j==arr.length-1){
ccase=ccase+arr[i][j];
}
}
}
System.out.println(psum+ssum-(ccase/2));n
}
public static void main(String[] args){
int arr[][]={{1,2,3},{4,5,6},{7,8,9}};
Diagnol(arr);
}
}*/