using System;
namespace Taller_Matrices_punto_uno
{
class MainClass
{
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 aleatorio = new Random();
int cont =0, cont2 =0, suma=0;
double porcentajepar,porcentajeinpar,promedio;
for (int f = 0; f < N; f++){
for (int c = 0; c < M; c++){
matriz[f,c] = aleatorio.Next(1, 101);
suma += matriz[f,c];
}
}
for (int f = 0; f < N; f++){
Console.WriteLine("");
for (int c = 0; c < M; c++){
Console.Write(matriz[f,c]+"\t");
if (matriz[f,c]%2 == 0){
cont ++;
}
else{
cont2 ++;
}
}
}
porcentajepar = cont * 100 / (N*M);
porcentajeinpar = cont2 * 100 / (N*M);
promedio = suma / (N*M);
Console.WriteLine(" ");
Console.WriteLine("La Suma total de los elementos es: "+suma);
Console.WriteLine($"El promedio de la suma total es: {promedio:f1}");
Console.WriteLine("Cantidad N pares :"+cont);
Console.WriteLine("Cantidad N inpares :"+cont2);
Console.WriteLine($"Porcentaje de N pares : {porcentajepar:f1} %");
Console.WriteLine($"Porcentaje de N inpares : {porcentajeinpar:f1} %");
}
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: