20091109

PRACTICA 8.2 ARREGGLO LLAMADO EMAX(visual)





Del ejercicio 8.1 para el inciso a y b es el mismo codigo eso se entedio durante la clase., si hay aogun problema con esto haganmelo saber,


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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
int[] Emax = new int[10];
int I, mayor, pos = 0;
public Form1()
{
InitializeComponent();
I = 0;
listBox1.Items.Add("");
}
private void button1_Click(object sender, EventArgs e)
{
if (I <>
{
Emax[I] = int.Parse(textBox1.Text);
if (I == 0)
{ mayor = Emax[0];
}
textBox1.Focus(); textBox1.Clear(); listBox1.Items.Add(I.ToString() + ":\t" + Emax[I].ToString()); if (Emax[I] > mayor)
{
mayor = Emax[I];
pos = I;
}
I++;
}
else
{
button1.Enabled = false;
}
}
private void button2_Click(object sender, EventArgs e)
{
listBox1.Items.Add ("El valor maximo es: " + mayor.ToString());
listBox1.Items.Add ("Posicion numero: " + pos.ToString());
}
private void button3_Click(object sender, EventArgs e)
{
I = 0;
textBox1.Clear();
listBox1.Items.Clear();
}
private void button4_Click(object sender, EventArgs e)
{
Close();
}
}
}


A continuacion el codigo en ejecutable visual del inciso c).





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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
int[] Emax = new int[10];
int I, mayor, pos = 0;
public Form1()
{
InitializeComponent();
I = 0;
listBox1.Items.Add("");
}
private void button1_Click(object sender, EventArgs e)
{
if (I < i ="="" mayor =" Emax[0];" mayor =" Emax[I];" pos =" I;" enabled =" false;" i =" 0;">

PRACTICA 8.2 ARREGLO LLAMADO EMAX.(consola)

pseudocodigo.
inicio

int[] emax = new int[10]
int I, mayor

print"INTRODUCE DATO"
Read emax[0]
mayor = emax[0]
for (I = 1 to i<=e step I++) { print "INTRODUCE DATO ", I Read emax[I] if (emax[I] > mayor)
{
mayor = emax[I]
}
}
print " LISTA DE 10 NUMERO ESNTEROS")
for (I = O to I++)
{
print (emax[I])
}
print"EL VALOR MAXIMO ES : ", mayor
}
fin















Escriba un programa para introducir 10 numeros enteros en un arreglo llamado emax y encuentre el maximo valor introducido, el programa debe contener solo una gaza o ciclo y el maximo debe determinarse al introducri los valores de los elementos del arreglo(sugerencias: establesca el mayor numero igual al primer elemento del arreglo, el cual debe ser aprtado antes de la gaza que se utilizara para introducir los demas valores del arreglo.




using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int[] emax = new int[10];
int I, mayor;
Console.WriteLine("\tINTRODUCE DATO");
emax[0] = int.Parse(Console.ReadLine());
mayor = emax[0];
for (I = 1; I <>
{

Console.WriteLine("\tINTRODUCE DATO {0}", I);

emax[I] = int.Parse(Console.ReadLine()); if (emax[I] > mayor)
{
mayor = emax[I];
}
}
Console.WriteLine("\t LISTA DE 10 NUMERO ESNTEROS");
for (I = 0; I <>
{

Console.WriteLine(emax[I]);

} Console.WriteLine("\tEL VALOR MAXIMO ES {0}: ", mayor);

Console.ReadLine();

}

}

}








b)


repita el ejercicio del inciso A , pero siga el rastro del maximo elemento del arreglo y de el numero del indice para el maximo. despues de desplegar los numeros, imprima estos dos mensajes. el valormaximo es :, este es el elemento numero__en la lista de numeros.








using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int[] emax = new int[10];
int I, mayor, s = 0;
Console.WriteLine("INTRODUCE NUMERO");
emax[0] = int.Parse(Console.ReadLine());
mayor = emax[0];
for (I = 1; I <> mayor)
{
mayor = emax[I];
s = I;
}
}
Console.WriteLine("LISTA DE 10 NUMEROS ENTEROS");
for (I = 0; I <> {
Console.WriteLine(emax[I]);
}
Console.WriteLine("EL VALOR MAXIMO ES {0}: ", mayor);
Console.WriteLine("ESTE ES ELEMENTO NUMERO__ {0} dDE LA LISTA DE NUMEROS", s); Console.ReadLine(); }
}}






C)


Repita el ejercicio B, pero haga que el programa localice el menor de los datos introducidos.











using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int[] emax = new int[10];
int I, mayor, s = 0;
Console.WriteLine("INTRODUCE NUMERO");
emax[0] = int.Parse(Console.ReadLine());
mayor = emax[0];
for (I = 1; I <> {
Console.WriteLine("INTRODUCE DATO{0}", I);
emax[I] = int.Parse(Console.ReadLine());
if (emax[I] <>
{
mayor = emax[I]; s = I;
} }
Console.WriteLine("LISTA DE 10 NUMEROS ENTEROS");
for (I = 0; I <>
{
Console.WriteLine(emax[I]);
} Console.WriteLine("EL VALOR MINIMO INTRODUCIDO ES {0}: ", mayor);
Console.WriteLine("ESTE ES ELEMENTO NUMERO__ {0} dDE LA LISTA DE NUMEROS", s);
Console.ReadLine();
}
} }

PRACTICA 8.1ARREGLO LLAMADO TEMP.(visual)



CODIGO EJECUTABLE DEL PROGRAMA 8.1. A CONTINUACION


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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
int[] temp;
int I, suma, P;
public Form1()
{
InitializeComponent();
temp = new int[8];
I = suma = P = 0;
listBox1.Items.Add("");
}
private void button1_Click(object sender, EventArgs e)
{
if (I < 8)
{
temp[I] = int.Parse(textBox1.Text);
suma = suma + temp[I];
listBox1.Items.Add(temp[I]);
textBox1.Clear();
textBox1.Focus();
I++;
}
else
{
textBox1.Clear();
textBox1.Enabled = false;
button1.Enabled = false;
}
}
private void button2_Click(object sender, EventArgs e)
{
P = suma / 8;
listBox1.Items.Add("Promedio=" + P.ToString());
}
private void button3_Click(object sender, EventArgs e)
{
I = 0;
textBox1.Clear();
listBox1.Items.Clear();
}
private void button4_Click(object sender, EventArgs e)
{
Close();
}
}
}

PRACTICA 8.1.ARREGLO LLAMADO TEMP.(consola)

pseudocodigo.
inicio
int[] temp = new int[8]
int suma = 0, I, S
print"tINTRODUZCA 8 NUMEROS:"
for (I = 0 to I <8 step I++)
print("\n\t\t NUMERO:", I)
Read temp[I] suma += temp[I] S = suma / 8
print " LISTADO DE 8 VALORES :"
for (I = 0 to I <8 step I++)
{
print"t" + temp[I] } print" PROMEDIO = ", S
}fin.



Escriba un programa para introducir 8 números den un arreglo llamado temp. Al introducir cada numero, súmelo aun total. Después e introducir todos los números y el promedio.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int[] temp = new int[8];
int suma = 0, I, S;

Console.WriteLine("\n\t\tINTRODUZCA 8 NUMEROS:");
for (I = 0; I <8;i++) color="#cc66cc">{

Console.Write("\n\t\t NUMERO {0}:", I);
temp[I] = int.Parse(Console.ReadLine());
suma += temp[I];
}
S = suma / 8;
Console.WriteLine("\n\t LISTADO DE 8 VALORES :");
for (I = 0; I <8;i++) color="#cc66cc">{
Console.WriteLine("\t\t\t" + temp[I]);
} Console.WriteLine("\n\t\t PROMEDIO = {0}", S);
Console.ReadKey();
}
} }

20091103

PRACTICA 7.5 SUMA DE IMAPRES Y PARES (visual)(consola)

pseudocodigo
inicio
double n
int x
double sumaimpar = 0.0
double sumapar = 0.0
print "INTRODUCE EL NUMERO "
Read n;
for (x = 1 to x <= n step x = x + 1)
{
if (x == 1) sumaimpar = sumaimpar + x;
else { sumapar = sumapar + x;
} }
print "LA SUMA DE LOS NUMEROS IMPARESES: ", sumaimpar print"LA SUMA DE LOS NUMEROS PARES ES ", sumapar
while(sumapar >sumaimpar)
{
print"LA SUMA DE LOS PARES ES MAYOR"
}
fin.










A continuacion el ejecutable de la suma de pares e impares.

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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
double n;
int x;
double sumaimpar = 0.0;
double sumapar = 0.0;
n = int.Parse(textBox1.Text);
for (x = 1; x <= n; x = x + 1) { if (x % 2 == 1)

{
sumaimpar = sumaimpar + x;
}
else
{
sumapar = sumapar + x;
}
} textBox2.Text = ("LA SUMA DE LOS NUMEROS IMPARES ES=" + sumaimpar.ToString()); textBox3.Text = ("LA SUMA DE LOS NUMEROS PARES ES=" + sumapar.ToString()); } } }











PRACTICA 7.5 SUMA DE IMAPRES Y PARES (consola)


EJECUTABLE EN CONSOLA





using System;
using System.Collections.Generic;

class Program
{
static void Main(string[] args)
{
double n;
int x;
double sumaimpar = 0.0;
double sumapar = 0.0;
Console.WriteLine("\tINTRODUCE EL NUMERO ");
n = double.Parse(Console.ReadLine());
for (x = 1; x <= n; x = x + 1) { if (x % 2 == 1)

{

sumaimpar = sumaimpar + x;

} else

{

sumapar = sumapar + x;

}

} Console.WriteLine("\tLA SUMA DE LOS NUMEROS IMPARESES: {0}", sumaimpar); Console.WriteLine("\tLA SUMA DE LOS NUMEROS PARES ES {0}", sumapar);

while(sumapar >sumaimpar)
{
Console.WriteLine("\tLA SUMA DE LOS PARES ES MAYOR");
Console.ReadKey();
}
}
}
}

PRACTICA 9.1 CALIFICACIONES Y PROMEDIOS (visual)





A continuacion el ejecutble en visual.


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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
int[] calificaciones;
int[] desviacion;
int I, suma, variancia, promedio;
public Form1()
{
InitializeComponent();
calificaciones = new int[] { 89, 95, 72, 83, 99, 54, 86, 75, 92, 73, 79, 75, 82, 73 };
desviacion = new int[14];
suma = I = variancia = promedio = 0;
}
private void button1_Click(object sender, EventArgs e)
{
listBox1.Items.Add("CALIFICACION DESVIACION");
for (I = 0; I < 14; I++)
{
suma = suma + calificaciones[I];
}
promedio = suma / 14;
for (I = 0; I < 14; I++)
{
desviacion[I] = calificaciones[I] - promedio;
listBox1.Items.Add(calificaciones[I] + "\t" + desviacion[I]);
}
suma = 0;
for (I = 0; I < 14; I++)
{
suma = suma + (desviacion[I] *desviacion[I]);
}
variancia = suma / 14;
listBox1.Items.Add(" LA VARIANCIA "+variancia);


}
private void button2_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
}
private void button3_Click(object sender, EventArgs e)
{
Close();
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}

PRACTICA 9.1 CALIFICACIONES Y PROMEDIOS(consola)

pseudocodigo.
inicio
int[] calificaciones = { 89, 95, 72, 83, 99, 54, 86, 75, 92, 73, 79, 75, 82, 73 };
int[] desviacion = new int[14]
int suma = 0, varianza, promedio
int I
for (I = 0 to I < promedio =" suma" i =" 0" i =" 0" suma =" 0" i =" 0" suma =" suma" varianza =" suma" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuaT_zJ_py_SYcSXGw6OjYqrCCl3H0Fp0raSZMNarUBDe8NeF6A_rlSD7r_pYkoxKF_s07dY2KbnyXfo1228WFPCviqE1FouY_WqADnjFsWvSEUei-y0KrmzVAfB6QfzJaW0U4N3qj4NAf/s1600-h/9.0.bmp">

















Ejecutable del programa y calificaciones.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int[] calificaciones = { 89, 95, 72, 83, 99, 54, 86, 75, 92, 73, 79, 75, 82, 73 };
int[] desviacion = new int[14];
int suma = 0, varianza, promedio;
int I;
for (I = 0; I < suma =" suma)
}
promedio = suma / 14;
for (I = 0; I <14;i++)>{
desviacion[I] = calificaciones[I] - promedio;
}
Console.WriteLine("CALIFICACION DESVIACION ");
for (I = 0; I <14;i++)>{
Console.WriteLine("\t{0}\t{1}", calificaciones[I], desviacion[I]);
}
suma = 0; for (I = 0; I <14;i++)>{
suma = suma + (desviacion[I] * desviacion[I]);
}
varianza = suma / 14; Console.WriteLine("\n LA VARIANZA ES____ " + varianza); Console.ReadKey();
}
}
}