Wednesday, October 29, 2008

Practica 7 Consola

Programa que capturas el numero de estaciones cualesquieras y sus meses, capturando el responsable de cada estacion y su produccion, por ultimo desplegara la produccion de cada estacion y cual es la mas productiva..






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

namespace Aplicacion_Consola_Estaciones_de_trabajo
{

class ArregloUnidimensional
{
object[] lista;
public ArregloUnidimensional(int n)
{
lista = new object[n];
}
public void asignarDato(int indice, object dato)
{
lista[indice] = dato;
}
public object obtenerDato(int indice)
{
return lista[indice];
}
public object[] Lista
{
get { return lista; }
set { lista = value; }
}
}

class ArregloBidimensional
{
object[,] Matriz;

public ArregloBidimensional(int M, int N)
{
Matriz = new object[M, N];

}
public void asignarDato(int reng, int col, object dato)
{
Matriz[reng, col] = dato;
}
public object obtenerDato(int reng, int col)
{
return Matriz[reng, col];
}
public object[,] matriz
{
get { return Matriz; }
set { Matriz = 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());
ArregloBidimensional B = new ArregloBidimensional (num, meses + 1);
ArregloUnidimensional nom = new ArregloUnidimensional (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 es {0}", mayor);

for (r = 0; r < num; r++)
{
Console.WriteLine("\n\nNo de estacion {0}", r + 1);
Console.WriteLine("Responsable {0}", nom.obtenerDato(r));
Console.WriteLine("Total de la produccion :{0} ", B.obtenerDato(r, meses));

}
Console.ReadLine();

}
}
}

Practica 7 Visual




using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
public partial class frmPractica7 : Form
{


int[,] Matriz;
string[] Nombres;
int R, C;
int M, N;

public frmPractica7()
{
InitializeComponent();
R = C = 0;
M = N = 0;
}

private void button1_Click(object sender, EventArgs e)
{
M = int.Parse(txtestaciones.Text);
N = int.Parse(txtnmeses.Text);
Nombres = new string[M];
Matriz = new int[M, N + 1];
txtestaciones.Enabled = false;
txtnmeses.Enabled = false;
cmdaceptar.Enabled = false;
txtnestacion.Text = (R + 1).ToString();
txtnumeromeses.Text = (C + 1).ToString();

txtproduccion.Focus();


}

private void button2_Click(object sender, EventArgs e)
{
if (R < M && C < N)
{
Matriz[R, C] = int.Parse(txtproduccion.Text);
Nombres[R] = txtresponsable.Text;
C++;
txtresponsable.Enabled = false;


if (C == N)

{
C = 0;
R++;
txtresponsable.Enabled = true;
txtresponsable.Clear();
}
if (R != M)
{
txtnestacion.Text = (R + 1).ToString();
txtnumeromeses.Text = (C + 1).ToString();
txtproduccion.Clear();

txtproduccion.Focus();

}
else
{
txtnestacion.Enabled = false;
txtnumeromeses.Enabled = false;
txtproduccion.Enabled = false;
txtresponsable.Enabled = false;
MessageBox.Show("Todos los datos fueron introducidos");
}
}
}

private void button3_Click(object sender, EventArgs e)
{
int Suma = 0;
lstagregar.Items.Add("No. Estacion Responsable Produccion");
for (R = 0; R < M; R++)
{
Suma = 0;

for (C = 0; C < N; C++)
{
Suma += Matriz[R, C];
}
Matriz[R, C] = Suma;
}
for (R = 0; R < M; R++)
{
lstagregar.Items.Add((R + 1).ToString() + " " + Nombres[R] + " " + Matriz[R, N].ToString());

}
}

private void frmPractica7_Load(object sender, EventArgs e)
{

}




private void cmdSalir_Click(object sender, EventArgs e)
{
Close();
}

}
}

Diagrama de flujo de practica 7

Diagrama de flujo de practica 5

Practica 6 visual



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Ejercicio_47
{
public partial class frmEjercicio47 : Form
{
public frmEjercicio47()
{
InitializeComponent();
}
//Declaracion de variables globales y arreglo
int[,] num = new int[4, 5];
int[] ordenar = new int[20];
int ren = 0;
int col = 0;
int p, i, m, r, c, j, k,me;
private void cmdtabla_Click(object sender, EventArgs e)
{

cmdnum.Enabled = true;
cmdtabla.Enabled = false;

//creacion de tabla aleatoria
Random aleatorio = new Random();

for (ren = 0; ren < 4; ren++)
{
for (col = 0; col < 5; col++)
{
num[ren, col] = aleatorio.Next(50);

txttabla.Text = txttabla.Text + num[ren, col] + "\t";
}
txttabla.Text = txttabla.Text + "\r\n";
}

}

private void cmdnum_Click(object sender, EventArgs e)
{
txttabla.Clear();
lblDespliegue.Visible = true;

for (p = 1; p <= 20; p++)
{
me = num[0, 0];
r = 0;
c = 0;
for (i = 0; i < 4; i++)
{
for (j = 0; j < 5; j++)
{
if (num[i, j] < me)
{
me = num[i, j];
r = i;
c = j;
}
}
}
ordenar[k] = me;
num[r, c] = 9999;
k++;

}

for (k = 0; k < 20; k++)
{
txttabla.Text = txttabla.Text + ordenar[k].ToString() + ", ";
}

}

private void cmdLimpiar_Click(object sender, EventArgs e)
{
cmdtabla.Enabled = true;
cmdnum.Enabled = false;
lbltabla.Visible = true;
lblDespliegue.Visible = false;
txttabla.Text = "";
txttabla.Clear();

}

private void cmdSalir_Click(object sender, EventArgs e)
{
Close();
}

private void lblDespliegue_Click(object sender, EventArgs e)
{

}

private void txttabla_TextChanged(object sender, EventArgs e)
{

}
}
}

Practica 3 Visual





using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
public partial class frmPrograma3 : Form
{
int Ceconomica = 10;
int i = 0;
int I = 10;
int[] avion = new int[30];
int Primerac = 0;
public frmPrograma3()
{
InitializeComponent();
}

private void cmdAvion_Click_1(object sender, EventArgs e)
{
if (PrimeraClase.Checked)
{
if (Primerac < 10)
{

label2.ForeColor = System.Drawing.Color.Green;
label2.Text="Asiento # "+ (i+ 1)+ " Primera Clase";

avion[Primerac] = 1;
Primerac++;
i++;

}


else
{
MessageBox.Show("Primera Clase Llena \nSi decea seleccione la opcion de Clase economica");
PrimeraClase.Enabled = false;
PrimeraClase.Checked = false;

}

}


if (Claseconomica.Checked)
{

if (Ceconomica < 30)
{

label3.ForeColor = System.Drawing.Color.Green;
label3.Text="Asiento # " + (I + 1) + " Clase Economica";
avion[Ceconomica] = 1;
Ceconomica++;
I++;


}

else
{


MessageBox.Show("Clase Economica Llena \n\nSi decea seleccione la opcion de Primera clase");
Claseconomica.Enabled = false;
Claseconomica.Checked = false;

}
}
}

private void frmPrograma3_Load(object sender, EventArgs e)
{

}

private void cmdSalir_Click(object sender, EventArgs e)
{
Close();
}

}

}