Primer programa
int[] vector = new int[100];
int[] elem = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int al = 0;
Random rnd = new Random();
for (int x = 0; x < 100; x++)
{
vector[x] = rnd.Next(1, 11);
Console.Write(vector[x] + " ");
al = vector[x];
if (al == 1)
{
elem[0]++;
}
else if (al == 2)
{
elem[1]++;
}
else if (al == 3)
{
elem[2]++;
}
else if (al == 4)
{
elem[3]++;
}
else if (al == 5)
{
elem[4]++;
}
else if (al == 6)
{
elem[5]++;
}
else if (al == 7)
{
elem[6]++;
}
else if (al == 8)
{
elem[7]++;
}
else if (al == 9)
{
elem[8]++;
}
else if (al == 10)
{
elem[9]++;
}
}
Console.WriteLine();
Console.WriteLine("Contador");
for (int x = 0; x<10,x++)
{
Console.WriteLine(x + 1 + ":" + elem[x]);
}
Segundo Programa
int[] al = new int[10];
for (int x = 0; x < 10; x++)
{
Console.WriteLine("Insertar elemento" + (x + 1));
al[x] = int.Parse(Console.ReadLine());
}
for (int x = 0; x < 10; x++)
{
Console.Write(al[x] + " ");
}
for (int x = 9; x >= 0; x--)
{
for (int y = 0; y < 10; y++)
{
if (al[x] == al[y] && y != x)
{ al[x] = 0; }
}
}
Console.WriteLine();
Console.WriteLine("repetidos eleminado.");
for (int x = 0; x < 10; x++)
{
Console.Write(al[x] + " ");
}
Tercer Programa
int aux = 0, y = 0, z = 0, max = 0, poss = 0;
int[] vals = new int[10];
String[] estados = { "Sonora", "Aguascalientes", "Oaxaca", "Colima",
"Chihuahua", "San Luis Potosi", " Durango",
"Veracruz", "Yucatán", "Tabasco"};
String[] meses = {"Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio",
"Julio", "Agosto",
"Septiembre", "Octubre", "Noviembre", "Diciembre"};
int[,] matriz =
{
{90, 90, 40, 60, 20, 80, 10, 10, 30, 70, 50, 25},
{100, 80, 50, 10, 60, 40, 100, 40, 80, 70, 100, 56},
{70, 90, 60, 20, 80, 50, 20, 60, 30, 70, 110, 60},
{50, 60, 50, 30, 20, 80, 50, 40, 20, 70, 200, 70},
{90, 90, 60, 40, 80, 70, 60, 40, 30, 50, 10, 40},
{40, 10, 50, 40, 30, 90, 30, 80, 80, 60, 90, 86},
{100, 40, 20, 50, 10, 100, 90, 80, 100, 70, 130, 120},
{70, 10, 90, 70, 50, 30, 70, 60, 20, 50, 40, 89},
{40, 30, 40, 70, 10, 100, 20, 20, 70, 20, 90, 66},
{10, 60, 100, 50, 60, 40, 50, 100, 90, 20, 15, 30}
};
for (int x = 0; x < 10; x++)
{
for (y = 0; y < 12; y++)
{
aux += matriz[x, y];
}
z++;
vals[z - 1] = aux;
aux = 0;
}
for (int x = 0; x < 10; x++)
{
Console.Write(vals[x] + " ");
if (vals[x] > max)
{
max = vals[x];
poss = x;
}
}
Console.WriteLine();
Console.WriteLine("El estado con mayor precipitacion es: " +
estados[poss]);
max = 0;
for (int x = 0; x < 10; x++)
{
Console.Write(vals[x] + " ");
if (vals[x] < max)
{
max = vals[x];
poss = x;
}
}
Console.WriteLine();
Console.WriteLine("El estado con menor precipitacion es: " +
estados[poss]);
max = 0;
for (y = 0; y < 12; y++)
{
if (matriz[1, y] > max)
{
max = matriz[1, y];
poss = y;
}
}
Console.WriteLine();
Console.WriteLine("El mes con menor precipitacion es: " + meses[poss])
Tercero
int = 0, y, z = 0, max = 0, poss = 0;
int[] vals = new int[10];
String[] estados = { "Sonora", "Aguascalientes", "Oaxaca", "Colima",
"Chihuahua", "San Luis Potosi", " Durango",
"Veracruz", "Yucatán", "Tabasco"};
String[] meses = {"Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio",
"Julio", "Agosto",
"Septiembre", "Octubre", "Noviembre", "Diciembre"};
int[,] matriz =
{
{90, 90, 40, 60, 20, 80, 10, 10, 30, 70, 50, 25},
{100, 80, 50, 10, 60, 40, 100, 40, 80, 70, 100, 56},
{70, 90, 60, 20, 80, 50, 20, 60, 30, 70, 110, 60},
{50, 60, 50, 30, 20, 80, 50, 40, 20, 70, 200, 70},
{90, 90, 60, 40, 80, 70, 60, 40, 30, 50, 10, 40},
{40, 10, 50, 40, 30, 90, 30, 80, 80, 60, 90, 86},
{100, 40, 20, 50, 10, 100, 90, 80, 100, 70, 130, 120},
{70, 10, 90, 70, 50, 30, 70, 60, 20, 50, 40, 89},
{40, 30, 40, 70, 10, 100, 20, 20, 70, 20, 90, 66},
{10, 60, 100, 50, 60, 40, 50, 100, 90, 20, 15, 30}
};
for (int x = 0; x < 10; x++)
{
for (y = 0; y < 12; y++)
{
aux += matriz[x, y];
}
z++;
vals[z - 1] = aux;
aux = 0;
}
for (int x = 0; x < 10; x++)
{
Console.Write(vals[x] + " ");
if (vals[x] > max)
{
max = vals[x];
poss = x;
}
}
Console.WriteLine();
Console.WriteLine("El estado con mayor precipitacion es: " +
estados[poss]);
max = 0;
for (int x = 0; x < 10; x++)
{
Console.Write(vals[x] + " ");
if (vals[x] < max)
{
max = vals[x];
poss = x;
}
}
Console.WriteLine();
Console.WriteLine("El estado con menor precipitacion es: " +
estados[poss]);
max = 0;
for (y = 0; y < 12; y++)
{
if (matriz[1, y] > max)
{
max = matriz[1, y];
poss = y;
}
}
Console.WriteLine();
Console.WriteLine("El mes con menor precipitacion es: " + meses[poss]);