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 aleatorio = new Random();
int suma=0, cont=0, pos=0, pos1=0;
bool band = false;
for (int f = 0; f < N; f++){
for (int c = 0; c < M; c++){
matriz[f,c] = aleatorio.Next(10, 100);
}
}
for (int f = 0; f < N; f++){
Console.WriteLine("");
for (int c = 0; c < M; c++){
Console.Write(matriz[f,c]+"\t");
}
}
Console.Write("\n\n");
Console.Write("Filas Impares");
for (int f = 0; f < N; f ++){
Console.WriteLine("");
for (int c = 0; c < M; c ++){
if (f%2 == 1){
suma += matriz[f,c];
Console.Write(matriz[f,c]+"\t");
}
else {
if(matriz[f,c]%2==1)
cont ++;
}
}
}
Console.WriteLine($"\nla suma de las filas impares es: {suma}");
Console.WriteLine($"la cantidad de elementos impares que hay en las filas pares es: {cont}");
int numero = Convert.ToInt32(Console.ReadLine());
for (int f = 0; f < N; f++){
for (int c = 0; c < M; c++){
if (matriz[f,c] == numero){
band = true;
pos = f;
pos1 = c;
}
}
}
Console.WriteLine(band == true? "existe en pos :[" +(pos+1)+","+(pos1+1)+"]":"No existe");
}
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: