miércoles, 9 de diciembre de 2009

PRACTICAS EXTRAS 13 EXAMNE 3 CONSOLA Y VISUAL

SPEUDOCODIGO

int[] x = { 1, 2, 3, 4, 5, 6, 7, 8, 9,10};

int maximo = x[0];

int minimo = x[0];

int N = 0, intervalo = 0;

for (N = 0 to N <= 15 step N++)

{

for (N = 0 to N <>

{

if (x[N] > maximo)

{

maximo = x[N];

}

if (x[N] <>

{

minimo = x[N];

}

}

intervalo = maximo - minimo;

print"El intervalo de los valores del arreglo x es:{0} ",intervalo;

fin

CONSOLA
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EXAMEN_3_CONSOLA
{
class Program
{
static void Main(string[] args)
{
int[] x = { 1, 2, 3, 4, 5, 6, 7, 8, 9,10};
int maximo = x[0];
int minimo = x[0];
int N = 0, intervalo = 0;
for (N = 0; N <= 15; N++)
{
for (N = 0; N <>
{
if (x[N] > maximo)
{
maximo = x[N];
}
if (x[N] <>
{
minimo = x[N];
}
}
intervalo = maximo - minimo;

Console.WriteLine("El intervalo de los valores del arreglo x es:{0} ", intervalo);
Console.ReadKey();
}

}
}
}

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

namespace EXAMEN_3_VISUAL
{
public partial class Form1 : Form
{
int N, maximo, minimo, intervalo;
int[] x;

public Form1()
{
InitializeComponent();
x = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
maximo = x[0];
minimo = x[0];

}

private void button1_Click(object sender, EventArgs e)
{
for (N = 0; N <>
{
if (x[N] > maximo)
{
maximo = x[N];
}
if (x[N] <>
{
minimo = x[N];
}
}
intervalo = maximo - minimo;

listBox1.Items.Add("El intervalo de los valores del arreglo x es: " + intervalo.ToString());

}

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



PRACTICA 12 CONSOLA

PESUDOCODIGO
int suma = 0, mayor = 0, np = 0, diap = 0;
int r, c;
string plantas[12];
int[,] produccion[13, 8];
for (r = 0; r <>
{
Print "Nombre Planta",r+1
Read plantas [r]
suma=0;
for (c = 0; c <>
{
Print "Producto de la planta", r + 1)
Print "Dia”, c + 1
Read produccion[r, c]
suma = suma + produccion[r, c];
}
produccion[r, 7] = suma;
}
for (c = 0; c <>
{
suma = 0;
for (r = 0; r <>
{
suma = suma + produccion[r, c];
}
produccion[12, c] = suma;
}
for (r = 0; r <>
{
if (produccion[r, 7] > mayor)
{
mayor = produccion[r, 7];
np = r + 1;
}
}
Print "Plantas mas productivas ", np + 1
Print "Produccion de la pantal mas productiva ", produccion[np, 7]
mayor = 0;
for (c = 0; c <>
{
if (produccion[12, c] > mayor)
{
mayor = produccion[12, c];
diap = c + 1;
}
}
Print "Dia con mayor produccion:"
switch(diap)
{
case 1: print "Lunes"
break;
case 2: print "Martes"
break;
case 3: print "Miercoles"
break;
case 4: print "Jueves"

break;
case 5: print "Viernes"
break;
case 6: print "Sabado"
break;
case 7: print "Domingo"
break;
}
Print "Mayor Produccion en un dia", mayor
FIN

CONSOLA
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PRACTICA_12_CONSOLA
{
class Program
{
static void Main(string[] args)
{
int suma = 0, mayor = 0, np = 0, diap = 0;
int r, c;
string[] plantas = new string[12];
int[,] produccion = new int[13, 8];
for (r = 0; r <>
{
Console.WriteLine("Nombre Planta {0}", r + 1);
plantas[r] = Console.ReadLine();
suma = 0;
for (c = 0; c <>
{
Console.WriteLine("Producto de la planta {0}", r + 1);
Console.WriteLine("Dia {0}", c + 1);
produccion[r, c] = int.Parse(Console.ReadLine());
suma = suma + produccion[r, c];
}
produccion[r, 7] = suma;
}
for (c = 0; c <>
{
suma = 0;
for (r = 0; r <>
{
suma = suma + produccion[r, c];
}
produccion[12, c] = suma;
}
for (r = 0; r <>
{
if (produccion[r, 7] > mayor)
{
mayor = produccion[r, 7];
np = r + 1;
}
}
Console.WriteLine("Plantas mas productivas {0}", np + 1);
Console.WriteLine("Produccion de la pantal mas productiva {0}", produccion[np, 7]);
mayor = 0;
for (c = 0; c <>
{
if (produccion[12, c] > mayor)
{
mayor = produccion[12, c];
diap = c + 1;
}
}
Console.WriteLine("Dia con mayor produccion:");
switch (diap)
{
case 1: Console.WriteLine("Lunes");
break;
case 2: Console.WriteLine("Martes");
break;
case 3: Console.WriteLine("Miercoles");
break;
case 4: Console.WriteLine("Jueves");
break;
case 5: Console.WriteLine("Viernes");
break;
case 6: Console.WriteLine("Sabado");
break;
case 7: Console.WriteLine("Domingo");
break;
}
Console.WriteLine("Mayor Produccion en un dia {0}", mayor);
Console.ReadKey();
}
}
}








PRACTICA 11CONSOLA Y WINDOWS


PSEUDOCODIGO:
int posc=0, posr=0;
int mayor=0;
int r,c;
int [,]numeros={{16,22,99,4,18},{-258,4,101,5,98},{105,6,15,2,45},{33,88,72,16,3}};
for r = 0; to 3 step r=r+1
{
for c = 0 to 4 step c=c+1
{
if (numeros[r, c] > mayor)
{
mayor = numeros[r, c];
posc = c+1;
posr = r+1;


}
else
{
}
Print("la matriz conformada por:{0}", numeros[r, c]);

}


}
Print("el dato mayor es: {0}", mayor);
Print("en el renglon : {0}", posr);
Print("en la columna : {0}", posc);
Fin
CONSOLA
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PRACTICA_11_CONSOLA
{
class Program
{
static void Main(string[] args)
{
int posc=0, posr=0;
int mayor=0;
int r,c;
int [,]numeros={{16,22,99,4,18},{-258,4,101,5,98},{105,6,15,2,45},{33,88,72,16,3}};
for (r = 0; r <= 3; r++)
{
for (c = 0; c <= 4; c++)
{
if (numeros[r, c] > mayor)
{
mayor = numeros[r, c];
posc = c+1;
posr = r+1;


}
else
{
}
Console.WriteLine("la matriz conformada por:{0}", numeros[r, c]);

}


}
Console.WriteLine("el dato mayor es: {0}", mayor);
Console.WriteLine("en el renglon : {0}", posr);
Console.WriteLine("en la columna : {0}", posc);
Console.ReadKey();
}
}
}


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

namespace PRACTICA_11_WINDOWS
{
public partial class Form1 : Form
{
int posc, posr, mayor;
int r, c;
int[,] numeros = { { 16, 22, 99, 4, 18 }, { -258, 4, 101, 5, 98 }, { 105, 6, 15, 2, 45 }, { 33, 88, 72, 16, 3 } };

public Form1()
{
InitializeComponent();
posc = posr = mayor = 0;
listBox1.Items.Add("los elementos de la matriz son :");
}

private void button1_Click(object sender, EventArgs e)
{
for (r = 0; r <= 3; r++)
{
for (c = 0; c <= 4; c++)
{
if (numeros[r, c] > mayor)
{
mayor = numeros[r, c];
posc = c + 1;
posr = r + 1;


}
else
{
}
listBox1.Items.Add("en el renglon:" + posr + "en la columna" + posc + "el numero" + numeros[r, c]);

}

}
listBox1.Items.Add("el dato mayor en el arrego es:" + mayor);
listBox1.Items.Add("en el renglon:" + posr);
listBox1.Items.Add("en la columna:" + posc);
}

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


PRACTICA 11.3 CONSOLA Y WINDOS

SPEUDOCODIGO
int[,] ciudad = new int[10, 29];
int ave, calle, a, c, sigue, ac, mayor = 0,mayor2 = 0,mayor3 = 0;
int posave = 0,posave2 = 0,posave3 = 0;
int poscalle = 0,poscalle2 = 0,poscalle3 = 0;
do
{
do
{
Print("introduce No de la avenida");
Read ave
if (ave <> 10)
{
Console.WriteLine("avenida erronea");
}
}
while (ave <> 10);
do
{
PRINT("introduce numero de calle");
READ calle
if (calle <30>58)
{
PRINT("calle erronea");
}
}
while ( calle <> 58);

PRINT("No de accidentes");
READ ac
ciudad [ ave - 1,calle - 30]=ac;
PRINT("presione 1 para continuar y 0 para terminar");
READ sigue
}
while (sigue ==1);

fora = 0 TO 9 STEP a =a+1
{
for( c=0 ; c <= 28 ; c++)
{
if (ciudad[a, c] > mayor)
{
mayor = ciudad[a, c];
posave = a + 1;
poscalle = c + 30;
}
else
{
if (ciudad[a,c] > mayor2)
{
mayor2 = ciudad[a, c];
posave2 = a + 1;
poscalle2 = c + 30;
}
else
{
if (ciudad[a, c] > mayor3)
{
mayor3 = ciudad[a, c];
poscalle3 = c + 30;
posave3 = a + 1;
}
else
{
}
}
}
}
}

PRINT( "la 1er interseccion mas peligrosa es entre ave {0}y la calle {1} con un numero de accidentes {2}",posave ,poscalle ,mayor);
PRINT("la 2da interseccion mas peligrosa es entre ave {0}y la calle {1} con un numero de accidentes {2}", posave2, poscalle2, mayor2);
PRINT("la 3ra interseccion mas peligrosa es entre ave {0}y la calle {1} con un numero de accidentes {2}", posave3, poscalle3, mayor3);

FIN


CONSOLA
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace practica_11._3_consola
{
class Program
{
static void Main(string[] args)
{
int[,] ciudad = new int[10, 29];
int ave, calle, a, c, sigue, ac, mayor = 0, mayor2 = 0, mayor3 = 0;
int posave = 0, posave2 = 0, posave3 = 0;
int poscalle = 0, poscalle2 = 0, poscalle3 = 0;
do
{
do
{
Console.WriteLine("introduce No de la avenida");
ave = int.Parse(Console.ReadLine());
if (ave <> 10)
{
Console.WriteLine("avenida erronea");
}
}
while (ave <> 10);
do
{
Console.WriteLine("introduce numero de calle");
calle = int.Parse(Console.ReadLine());
if (calle <> 58)
{
Console.WriteLine("calle erronea");
}
}
while (calle <> 58);

Console.WriteLine("No de accidentes");
ac = int.Parse(Console.ReadLine());
ciudad[ave - 1, calle - 30] = ac;
Console.WriteLine("presione 1 para continuar y 0 para terminar");
sigue = int.Parse(Console.ReadLine());
}
while (sigue == 1);

for (a = 0; a <= 9; a++)
{
for (c = 0; c <= 28; c++)
{
if (ciudad[a, c] > mayor)
{
mayor = ciudad[a, c];
posave = a + 1;
poscalle = c + 30;
}
else
{
if (ciudad[a, c] > mayor2)
{
mayor2 = ciudad[a, c];
posave2 = a + 1;
poscalle2 = c + 30;
}
else
{
if (ciudad[a, c] > mayor3)
{
mayor3 = ciudad[a, c];
poscalle3 = c + 30;
posave3 = a + 1;
}
else
{
}
}
}
}
}

Console.WriteLine("la 1er interseccion mas peligrosa es entre ave {0}y la calle {1} con un numero de accidentes {2}", posave, poscalle, mayor);
Console.WriteLine("la 2da interseccion mas peligrosa es entre ave {0}y la calle {1} con un numero de accidentes {2}", posave2, poscalle2, mayor2);
Console.WriteLine("la 3ra interseccion mas peligrosa es entre ave {0}y la calle {1} con un numero de accidentes {2}", posave3, poscalle3, mayor3);

Console.ReadKey();
}
}
}


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

namespace PRACTICA_11._3_WINDOWS
{
public partial class Form1 : Form
{
int[,] ciudad = new int[10, 29];
int ave, calle, ac, mayor, mayor2, mayor3, posave, poscalle, posave2, poscalle2, posave3, poscalle3;

public Form1()
{
InitializeComponent();
mayor = mayor2 = mayor3 = posave = poscalle = posave2 = poscalle2 = posave3 = poscalle3 = 0;
checkBox1.Checked = true;
listBox1.Items.Add("Accidentes");
}

private void button1_Click(object sender, EventArgs e)
{
ave = int.Parse(textBox1.Text);
calle = int.Parse(textBox2.Text);
ac = int.Parse(textBox3.Text);

checkBox1.Focus();
if ((checkBox1.Checked == true))
{
if (ave <> 10)
{
MessageBox.Show("avenida equivocada");
textBox1.Clear();
textBox3.Clear();
}
else
{
if (calle <> 58)
{
MessageBox.Show("calle equivocada");
textBox2.Clear();
textBox3.Clear();
}
else
{

if (ac > mayor)
{

ciudad[ave - 1, calle - 30] = ac;
mayor = ac;
posave = ave;
poscalle = calle;

}
else
{
if (ac > mayor2 )
{

ciudad[ave - 1, calle - 30] = ac;
mayor2 = ac;
posave2 = ave;
poscalle2 = calle;

}
if (ac > mayor3 )
{
ciudad[ave - 1, calle - 30] = ac;
mayor3 = ac;
posave3 = ave;
poscalle3 = calle;
}
else
{
}
}
}
}
listBox1.Items.Add("mayor" + mayor);
listBox1.Items.Add("posicion avenida" + posave);
listBox1.Items.Add("posicion calle" + poscalle);
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
}
else
{
button1.Enabled = false;
if (ave <> 10)
{
MessageBox.Show("avenida equivocada");
textBox1.Clear();
textBox3.Clear();
}
else
{
if (calle <> 58)
{
MessageBox.Show("calle equivocada");
textBox2.Clear();
textBox3.Clear();
}
else
{

if (ac > mayor)
{
ac = int.Parse(textBox3.Text);
ciudad[ave - 1, calle - 30] = ac;
mayor = ac;
posave = ave;
poscalle = calle;
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();

}
else
{
if (ac > mayor2 )
{
ac = int.Parse(textBox3.Text);
ciudad[ave - 1, calle - 30] = ac;
mayor2 = ac;
posave2 = ave;
poscalle2 = calle;
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
}
else
{
if (ac <>
{
ciudad[ave - 1, calle - 30] = ac;
mayor3 = ac;
posave3 = ave;
poscalle3 = calle;
}
else
{
}
}
}
}
}
}


}

private void button2_Click(object sender, EventArgs e)
{

listBox1.Items.Add("entre la avenida " + posave + " y la calle " + poscalle + " se produce la mayor cantidad de accidentes con:" + mayor);
listBox1.Items.Add("entre la avenida " + posave2 + " y la calle " + poscalle2 + " se produce la 2da mayor cantidad de accidentes con:" + mayor2);
listBox1.Items.Add("entre la avenida " + posave3 + " y la calle " + poscalle3 + " se produce la 3ra mayor cantidad de accidentes con:" + mayor3);

}

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