jueves, 30 de octubre de 2008

Practica 9

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int NG = 0, NoAlu = 0, mat = 0;
int suma = 0;
double promedio = 0;

Console.Write("\nCaptura numero de grupos: ");
NG = System.Int32.Parse(Console.ReadLine());
Console.Write("\nCaptura numero de alumnos: ");
NoAlu = System.Int32.Parse(Console.ReadLine());
Console.Write("\nCaptura numero de materias por alumno: ");
mat = System.Int32.Parse(Console.ReadLine());

int[, ,] kodex = new int[NG, NoAlu, mat];

for (int g = 0; g < NG; g++)
{
for (int a = 0; a < NoAlu; a++)
{
Console.Clear();
Console.WriteLine("Las calificaciones de los alumnos del grupo son{0}:", g + 1);
for (int m = 0; m < mat; m++)
{
Console.Write("\nintroduce calificacion {0} de alumno {1}: ", m + 1, a + 1);
kodex[g, a, m] = System.Int32.Parse(Console.ReadLine());
}
}
}
for (int g = 0; g < NG; g++)
{
Console.WriteLine("\nPromedio de los alumnosdel grupo{0}:", g + 1);
for (int a = 0; a < NoAlu; a++)
{
suma = 0;
for (int m = 0; m < mat; m++)
suma = suma + kodex[g, a, m];
{
promedio = suma / mat;
Console.WriteLine("Promedio de alumno{0}: {1}", a + 1, promedio);
}
}
Console.ReadLine();
}



}
}
}





lunes, 20 de octubre de 2008

Practica 8

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
double[,,] compañia;
int numS, noDep, dias;
Console.Write("Introduce el numero de sucursales:");
numS = int.Parse(Console.ReadLine());
Console.Write("Introduce el numero de departamentos:");
noDep = int.Parse(Console.ReadLine());
Console.Write("Introduce el numero de dias:");
dias = int.Parse(Console.ReadLine());
compañia = new double[numS, noDep, dias];
int p, s, t;
for (p = 0; p < numS; p++)
{
Console.WriteLine("Sucursal{0}: ", p + 1);
for (s = 0; s < noDep; s++)
{
Console.WriteLine("Departamento{0}: ", s + 1);
for (t = 0; t < dias; t++)
{
Console.Write(" Dia{0}:", t + 1);
compañia[p,s,t] = double.Parse(Console.ReadLine());
}
}
}
double suma = 0.0;
for (p=0; p < numS; p++)
{
suma = 0.0;
for (s=0; s < noDep; s++)
{
suma = 0.0;
for (t=0; t < dias; t++)
{
suma+ = compañia[p,s,t];
}
}
Console.WriteLine(" Numero de Sucursal:{0} ", p + 1);
Console.WriteLine("La venta total es:{0} ", suma);
}
Console.ReadLine();

}
}
}





Practica 7

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class ArregloBidimencional
{
object[,] arreglo;

public ArregloBidimencional(int m, int nm)
{
arreglo = new object[m, nm];

}
public void asignarDato(int reng, int col, object dato)
{
arreglo[reng, col] = dato;
}
public object obtenerDato(int reng, int col)
{
return arreglo[reng, col];
}
public object[,] Arreglo
{
get { return arreglo; }
set { arreglo = value; }
}

}
}
class ArregloUnidimencional
{
object[] arreglo;
public ArregloUnidimencional (int i)
{
arreglo = new object [i];
}
public void asignarDato(int j, object k)
{
arreglo[j] = k;
}
public object obtenerDato(int i)
{
return arreglo[i];
}
public object[] Arreglo
{
get { return arreglo; }
set { arreglo = value; }
}
}
}
class Program
{
static void Main(string[] args)
{
object datoNombre;
int suma = 0;

Console.Write("Introduce el numero de estaciones:");
int num = int.Parse(Console.ReadLine());
Console.Write("Introduce el numero de meses a evaluar:");
int meses = int.Parse(Console.ReadLine());
ArregloBidimencional B = new ArregloBidimencional(num, meses + 1);
ArregloUnidimencional nom = new ArregloUnidimencional(num);
int r, c, datoProd=0;
for (r = 0; r < num; r++)
{
Console.Write("Nombre del responsable de la estacion{0}:", r + 1);
datoNombre = Console.ReadLine();
nom.asignarDato(r, datoNombre);
suma = 0;
for (c = 0; c < meses; c++)
{
Console.Write("Produccion del mes{0}:", c + 1);
datoProd = int.Parse(Console.ReadLine());
B.asignarDato(r, c, datoProd);
suma = suma + datoProd;
}
B.asignarDato(r, c, suma);
}
int mayor = 0;
int renglon = 0;
for (r = 0; r < num; r++)
{
suma = (int)B.obtenerDato(r, meses);
if (suma > mayor)
{
mayor = (int)B.obtenerDato(r, meses);
renglon = r;
}
}
Console.WriteLine("\n\nEl numero de estacion con mayor produccion es{0}:", renglon + 1);
Console.WriteLine("Nombre del responsable{0}:", nom.obtenerDato(renglon));
Console.WriteLine("Total de la produccion:{0}", B.obtenerDato(r, meses));

Console.ReadLine();

}


}
}



Practica 6

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int [,] m = new int[4,5];
int[] ordenar = new int[20];
int I, J, R, C, P, menor, K = 0;
Console.WriteLine("introduce los siguientes enteros");
for (I=0; I < 4; I++)
{
for (J=0; J < 5; J++)
{
Console.Write("m[{0},{1}]:",I,J);
m[I, J] = int.Parse(Console.ReadLine());
}
}
for(P=1; P <= 20; P++)
{
menor = m [0,0];
R=0;
C=0;
for (I=0; I < 4; I++)
{
for(J=0; J < 5; J++)
{
if(m[I,J] < menor)
{
menor = m[I,J];
R=I;
C=J;
}
}
}
ordenar[K]=menor;
m[R,C]=9999;
K++;
}
Console.WriteLine("elementos ordenados de la matriz ordenados");
for(K=0; K < 20; K++)
{
Console.Write("{0,4}", ordenar[K]);
}
Console.ReadLine();
}

}
}





Practica 5

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n, m, r, c;
double suma = 0;
string[] nombres;
double[,] notas;

Console.WriteLine("introduce el numero de alumnos a registrar");
n = int.Parse(Console.ReadLine());

Console.WriteLine("Introduce el numero de calificaciones a registrar por cada alumnno");
m = int.Parse(Console.ReadLine());

nombres = new string[n];
notas = new double [n,m];
Console.WriteLine("Introduce los siguientes datos");

for (r=0; r < n; r++)
{
Console.WriteLine("Nombre Alumno {0}", r + 1);
nombres[r]= Console.ReadLine();

for (c=0; c < m; c++)
{
Console.WriteLine("Calificacion{0}", c + 1);
}
}

Console.WriteLine("Nombre del Alumno Calificaciones Promedio");
Console.WriteLine("----");

for (r=0; r < n; r++)
{
Console.Write("{0}", nombres[r]);
suma = 0.0;
for (c=0; c < m; c++)
{
Console.Write("\t{0}", notas[r, c]);
suma = suma + notas [r, c];
}
Console.WriteLine("\t\t\t {0}", suma / m);
}
Console.ReadLine();
}

}
}




martes, 7 de octubre de 2008

Practica 4b

Programa que clasifique cada una de las ciudades que son 5 y con cada número de empleado con los siguientes datos: (nombre del empleado, ciudad, número del empleado).

corrida de escritorio

using System;
using System.Collections.Generic;
using System.Text;

namespace WindowsApplication1
{
class Empleado
{
String NombreEmpleado;
int Ciudad;
int No_Empleado;
public Empleado (String Name, int City, int Number)
{
NombreEmpleado = Name ;
Ciudad = City;
No_Empleado = Number;
}
public Empleado()
{
NombreEmpleado= " ";
No_Empleado= 0;
Ciudad= " ";
}
public String nombreempleado
{
get { return NombreEmpleado; }
set { NombreEmpleado = value; }

}

public int ciudad
{
get { return Ciudad; }
set { Ciudad = value; }

}

public int no_empleado
{
get { return No_Empleado; }
set { No_Empleado = value;}

}


}

}

namespace WindowsApplication1
{
public partial class FrmEjercicio4b : Form
{
Empleado E1;
Empleado[] Empresa; int I;

public FrmEjercicio4b()
{
E1 = new Empleado();
I = 0;
InitializeComponent();
}

private void cmdAceptar_Click(object sender, EventArgs e)
{
int N = int.Parse(txtbNo_Datos.Text);
Empresa = new Empleado[N];
txtbNo_Datos.Enabled = false;
txtbName.Focus();

}
public void Ok Datos()
{
E1.nombreempleado = txtbName.Text;
E1.Ciudad = int.Parse(txtbCity.Text);
E1.no_empleado = int.Parse(txtnNumero.Text);
Empresa[I] = E1;
I++;
}

}
}


domingo, 5 de octubre de 2008

Practica 4a Rectangulo

Programa que saca el area y el perimetro
de un rectangulo, dando como unicos datos
el largo y el ancho del rectangulo.

corrida de escritorio

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Rectangulo
{
double largo, ancho;
public Rectangulo(double w, double h)
{
ancho = w;
largo = h;
}
public Rectangulo()
{
ancho = 1;
largo = 1;
}
public double area()
{
return largo * ancho;
}
public double perimetro()
{
return 2 * (largo + ancho);
}
public double Ancho
{
get { return ancho; }
set { ancho = value; }
}
public double Largo
{
get { return largo; }
set { largo = value; }
}
}



class Program
{
static void Main(string[] args)
{
Rectangulo unRect = new Rectangulo(10, 20);
Console.WriteLine("Datos de un rectangulo uno ");
Console.WriteLine(" ancho =" + unRect.Ancho + " ," + "largo= " + unRect.Largo);
Console.WriteLine("Area = {0} , Perimetro= {1}", unRect.area(), unRect.perimetro());
Console.WriteLine("\n\nDatos de un rectangulo dos ");
Rectangulo dosRect = new Rectangulo();
Console.WriteLine("\n ancho={0},largo={1} ", dosRect.Ancho, dosRect.Largo);
Console.WriteLine("Area={0} , perimetro= {1} ", dosRect.area(), dosRect.perimetro());

double L1, A1;
Console.WriteLine("\n\nDatos de un rectangulo tres ");
Console.Write("\n\nIntroduce el largo de un rectangulo : ");
L1 = double.Parse(Console.ReadLine());
Console.Write("Introduce el ancho de un rectangulo : ");
A1 = double.Parse(Console.ReadLine());
Rectangulo tresRect = new Rectangulo(A1, L1);

Console.WriteLine("\n ancho={0},largo={1} ", tresRect.Ancho, tresRect.Largo);
Console.WriteLine("Area={0} , perimetro= {1} ", tresRect.area(), tresRect.perimetro());


Console.ReadLine();
}
}
}