Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define MAX 100
- int main(void){
- int n, mat[MAX][MAX], flag1=1, flag2=1, min, max;
- scanf("%d", &n);
- for(int i=0; i<n; i++){
- for(int j=0; j<n; j++)
- scanf("%d", &mat[i][j]);
- }
- for(int i=0; i<n; i++){
- for(int j=0; j<n; j++){
- //min
- if((i+j)<(n-1)){
- if(flag1==1){
- min=mat[i][j];
- flag1=0;
- }
- if(mat[i][j]<min)
- min=mat[i][j];
- }
- //max
- if((i+j)>(n-1)){
- if(flag2==1){
- max=mat[i][j];
- flag2=0;
- }
- if(mat[i][j]>max)
- max=mat[i][j];
- }
- }
- }
- for(int i=0; i<n; i++){
- for(int j=0; j<n; j++){
- if((i+j)>(n-1))
- mat[i][j]=max;
- else if((i+j)<(n-1))
- mat[i][j]=min;
- else if((i+j)==(n-1))
- mat[i][j]=0;
- }
- }
- for(int i=0; i<n; i++){
- for(int j=0; j<n; j++){
- printf("%d ", mat[i][j]);
- }
- printf("\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement