Vous êtes sur la page 1sur 2

Ejercicio 9

int f, c, i, j,m,n;
int[,] matriz = new int[50, 50];
System.Console.WriteLine("mayor y menor elemento de una matriz");
System.Console.WriteLine("");
System.Console.WriteLine("ingrese el numero de filas de la matriz");
f=Convert.ToInt32(Console.ReadLine());
System.Console.WriteLine("ingrese el numero columnas de la matriz");
c=Convert.ToInt32(Console.ReadLine());
for (i = 0; i < f; i++)
for (j = 0; j < c; j++)
{
System.Console.WriteLine("M[" + (i + 1) + "," + (j + 1) + "]");
matriz[i, j] = Convert.ToInt32(Console.ReadLine());
}
Console.WriteLine();
for (i = 0; i < f; i++)
{
for (j = 0; j < c; j++)
{
Console.Write(matriz[i, j] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
m=matriz[0, 1];
n=matriz[0, 1];
for (i = 0; i < f; i++)
for (j = 0; j < c; j++)
{
if (matriz[i, j] >= m)
m = matriz[i, j];
if (matriz[i, j] <= n)
n = matriz[i, j];
}
System.Console.WriteLine("el mayor elemento es :"+m);
System.Console.WriteLine("el menor elemento es:"+n);
Console.Read();

Este es el ejercicio 10

Random r = new Random();


Console.Write("Ingrese el Nmero de Filas: ");
int filas = int.Parse(Console.ReadLine());
Console.Write("Ingrese el Nmero de Columnas: ");
int columnas = int.Parse(Console.ReadLine());
int[,] matriz = new int[filas, columnas];
int[,] inversa = new int[filas, columnas];

for (int i = 0; i < filas; i++)


for (int j = 0; j < columnas; j++)
matriz[i, j] = Convert.ToInt32(Math.Pow(r.Next(1, 6), 2));
Console.WriteLine(" Matriz Original ");
for (int i = 0; i < filas; i++)
{
for (int j = 0; j < columnas; j++)
Console.Write(string.Format("{0,4:D}", matriz[i, j]));
Console.WriteLine();
}
Console.WriteLine("La matriz inversa es ");
for (int i = 0; i < filas; i++)
{
for (int j = 0; j < columnas; j++)
{
inversa[i, j] = matriz[filas - i - 1, columnas - j - 1];
Console.Write(string.Format("{0,4:D}", inversa[i, j]));
}
Console.WriteLine();
}
Console.ReadKey();
Ejercicio 12

int n, i, j, x=0, y=0,s;


string p;
String[,]M = new string [5,6];
int[] v = new int[100];
System.Console.WriteLine("ingrese el numero de alumnos");
n = Convert.ToInt32(Console.ReadLine());
for (i = 0; i < n; i++)
{
for (j = 0; j < 6; j++)
{
System.Console.WriteLine("ingrese la clave de la pregunta:[" + (j + 1) +
"]");
p = Convert.ToString(Console.ReadLine());
System.Console.WriteLine("ingrese la alternativa marcada por el alumno:["
+ (i + 1) + "]" + "pregunta:[" + (j + 1) + "]");
M[i, j] = Convert.ToString(Console.ReadLine());
if ( M[i, j]==p)
x = x + 4;
if ( M[i, j]!=p)
y = y - 1;
}
s = x + y;
v[i] = s;
x = 0;
y = 0;
}
for (i = 0; i < n; i++)
System.Console.WriteLine("nota de alumno[" + (i + 1) + "]=" + v[i]);
Console.Read();

Vous aimerez peut-être aussi