-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImagine mediana.java
More file actions
26 lines (26 loc) · 873 Bytes
/
Imagine mediana.java
File metadata and controls
26 lines (26 loc) · 873 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
import java.util.*;
public class Eccpr{
public static void main(String [] args){
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
int m=sc.nextInt();
int [][]arr = new int [n+2][m+2];
for(int i=0;i<arr.length;i++){
for(int j=0;j<arr[i].length;j++){
if(i==0||i==arr.length-1)arr[i][j]=0;
else if(j==0||j==arr[i].length-1)arr[i][j]=0;
else arr[i][j]=sc.nextInt();
}
}
for(int i=1;i<arr.length-1;i++){
for(int j=1;j<arr[i].length-1;j++){
int []aux={arr[i-1][j],arr[i][j],arr[i+1][j],arr[i][j+1],arr[i][j-1]};
System.out.println(out(aux));
}
}
}
static int out(int []arr){
Arrays.sort(arr);
return arr[arr.length/2];
}
}