using System;

namespace MyCompiler {
    class Program {
        public static void Main(string[] args) {
            Console.WriteLine("Digite el valor de N (Cantidad de Filas)");
            int N = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Digite el valor de M (Cantidad de Columnas)");
            int M = Convert.ToInt32(Console.ReadLine());
            int [,]matriz = new int[N,M];
            
            Random r = new Random();
            for (int f = 0; f < N; f++){
                for (int c = 0; c < M; c++){
                    matriz[f,c] = (r.Next(1, 101));
                }
            }
            
            for (int f = 0; f < N; f++){
                Console.WriteLine("");
                for (int c = 0; c < M; c++){
                    Console.Write(matriz[f,c]+"\t");
                }    
            }
            Console.WriteLine("\n");
            Console.WriteLine("Diagonal Principal :");
            int mayor=matriz[0,0], pos1=0;
            for(int f = 0; f < N; f++){
                Console.Write($"{matriz[f,f]} ");
                if (matriz[f,f] > mayor) {
                    mayor = matriz[f,f];
                    pos1 = f;
                }
            }
            Console.WriteLine($"\nEl N mayor de la DP es: { mayor} en la pos {pos1+1 } ");
            Console.WriteLine("\n");
            
            Console.WriteLine("Diagonal Secundaria :");
            int menor=matriz[0,0],pos2=0;
            for(int f = 0, c = N-1;f < N ; f++){
                Console.Write($"{matriz[f,c]} ");
                if (matriz[f,c] < menor) {
                    menor = matriz[f,c];
                    pos2 = f;
                }
                c--;
            }
            Console.WriteLine($"\nEl N menor de la DS es: { menor} en la pos {pos2+1 } ");
            Console.WriteLine("\n");
            
            Console.Write("Elementos en posicion pares sumando fila y columna de f0 a c7");
             for (int f = 0; f < N; f ++){
                Console.WriteLine("");
                for (int c = 0; c < M; c ++){
                    if ((c + f)%2 == 0)
                    Console.Write(matriz[f,c]+"\t");
                }
             
            }
        }
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: