-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2D_Array_operations
More file actions
85 lines (68 loc) · 1.94 KB
/
Copy path2D_Array_operations
File metadata and controls
85 lines (68 loc) · 1.94 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package techinical_skill;
import java.util.Scanner;
public class sum_of_upper_digonal {
public static void main(String[] args) {
Scanner sc =new Scanner(System.in);
System.out.println("enter no of row of matrix");
int row=sc.nextInt();
System.out.println("enter no of col of matrix");
int col=sc.nextInt();
int [][]a=new int [row][col];
System.out.println("enter matrix elements");
for(int i=0;i<row;i++){
for(int j=0;j<col;j++){
a[i][j]=sc.nextInt();
}
}
int usum=0;
for(int i=0;i<row;i++){
for(int j=0;j<col;j++){
if(i<j){
usum+=a[i][j];
}
}
}
System.out.println("upper digonal sum"+ usum);
int lsum=0;
for(int i=0;i<row;i++){
for(int j=0;j<col;j++){
if(i>j){
lsum+=a[i][j];
}
}
}
System.out.println("lower digonal sum"+ lsum);
for(int i=0;i<row;i++){
int rowsum=0;
for(int j=0;j<col;j++){
rowsum+=a[i][j];
}
System.out.println("row sum"+ rowsum);
}
for(int i=0;i<row;i++){
int colsum=0;
for(int j=0;j<col;j++){
colsum+=a[j][i];
}
System.out.println("column sum"+ colsum);
}
int max=a[0][0];
for(int i=0;i<row;i++){
for(int j=0;j<col;j++){
if(max < a[i][j]){
max=a[i][j];
}
}
}
System.out.println(max);
int smax=a[0][0];
for(int i=0;i<row;i++){
for(int j=0;j<col;j++){
if(a[i][j]<max){
smax=a[i][j];
}
}
}
System.out.println("second largest"+ smax);
}
}