using System;
namespace MyCompiler {
class Program {
public static void Main(string[] args) {
//N = empresas y M = ciudades
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];
int sumatotal=0, contventas=0, continfeventas=0, contventascero=0;
int cantventas1=0, ventatotal4=0;
double promedio;
Random r = new Random();
for (int f = 0; f < N; f++){
for (int c = 0; c < M; c++){
matriz[f,c] = (r.Next(0,5000001));
sumatotal += matriz[f,c];
}
}
Console.Write("==============================================");
Console.Write("\nMedellin Bogota Cali Bquilla Cartagena Pasto");
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==============================================");
promedio = sumatotal / (N*M);
for (int f = 0; f < N; f++){
for (int c = 0; c < M; c++){
if (matriz[f,c] > promedio){
contventas ++;
}
}
}
for (int f = 0; f < N; f++){
for (int c = 0; c < M; c++){
if (matriz[f,c] <= promedio){
continfeventas ++;
}
}
}
for (int f = 0; f < N; f++){
for (int c = 0; c < M; c++){
if (matriz[f,c] == 0){
contventascero ++;
}
}
}
int mayor=matriz[0,0],pos1=0,pos2=0;
int menor=matriz[0,0],pos3=0,pos4=0;
for (int f = 0; f < N; f++){
for (int c = 0; c < M; c++){
if (matriz[f,c] > mayor) {
mayor = matriz[f,c];
pos1 = f;
pos2 = c;
}
if (matriz[f,c] < menor) {
menor = matriz[f,c];
pos3 = f;
pos4 = c;
}
}
}
bool band = false;
int pos5=0,pos6=0;
int dato = Convert.ToInt32(Console.ReadLine());
for (int f = 0; f < N; f++){
for (int c = 0; c < M; c++){
if (matriz[f,c] == dato){
band = true;
pos5 = f;
pos6 = c;
}
}
}
for (int f = 0; f < 10; f++){
for (int c = 0; c < M; c++){
if(matriz[f,c] >= 500000 && matriz[f,c] <= 1000000)
cantventas1 ++;
}
}
for (int f = 0; f < N; f++){
for (int c = 0; c < 5; c++){
ventatotal4 += matriz[f,c];
}
}
int cantventas2=0;
for (int f = 0; f < N; f++){
for (int c = 0; c < M; c+=2){
if(matriz[f,c] >= 1000000 )
cantventas2 ++;
}
}
int ventatotal10=0;
for (int f = N-1; f >= 10; f--){
for (int c = M-1; c >= 0; c--){
ventatotal10 += matriz[f,c];
}
}
int suma4=0,cont4=0;
double promedio4;
for (int f = 0; f < 5; f++){
for (int c = 0; c < M; c++){
suma4 += matriz[f,c];
cont4 ++;
}
}
promedio4 = suma4 / cont4;
int sumaprimer=0;
for (int f = 0; f < 1; f++){
for (int c = 0; c < M; c++){
sumaprimer += matriz[f,c];
}
}
int sumaultima=0;
for (int f = N-1; f >= 19; f--){
for (int c = M-1; c >= 0; c--){
sumaultima += matriz[f,c];
}
}
Console.WriteLine($"\nLa suma total de las ventas de todas las empresas es: {sumatotal:C0}");
Console.WriteLine($"Promedio del total de venta de todas las empresas es: {promedio:C2}");
Console.WriteLine($"La cantidad de ventas superior al promedio son: {contventas} ventas");
Console.WriteLine($"La cantidad de ventas inferiores o = al promedio son: {continfeventas} ventas");
Console.WriteLine($"La cantidad de ventas en 0 son: {contventascero} ventas");
Console.WriteLine($"La mayor venta es: {mayor} y su posicion es [{pos1},{pos2}]");
Console.WriteLine($"La menor venta es: {menor} y su posicion es [{pos3},{pos4}]");
Console.WriteLine(band == true? "si existe en pos :[" +pos5+","+pos6+"]":"ninguna empresa tiene este valor exacto");
Console.WriteLine($"La cantidad de ventas entre 500.000 y 1'000.000 en las primeras 10 empresas son: {cantventas1}");
Console.WriteLine($"La venta total de las primeras 4 ciudades es: {ventatotal4:C0}");
Console.WriteLine($"La cantidad de ventas superiores al millon en Med,Cali,Ctagena, es: {cantventas2}");
Console.WriteLine($"La venta total de las 10 ultimas empresas es: {ventatotal10:C0}");
Console.WriteLine($"El promedio de venta de las 4 primeras empresas es: {promedio4:F2}");
Console.WriteLine("La suma de ventas de la primera y ultima empresa es: "+ (sumaultima + sumaprimer));
}
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: