PSEUDOGODIGO
INT N;
[] INT VALORES;
PRINT (“Introduce numero de elementos");
READ N;
VALORES = NEW INT [N];
INT I;
INT sumapar=0;
INT sumaimpar=0;
FOR (I=0; I
PRINT (“Introduce valores enteros”);
READ VALORES[I];
IF ( VALORES [I]%2==0);
{
SUMAPAR +=VALORES[I];
}
ELSE
{
SUMIMPAR +=VALORES [I];
}}
PRINT (“Numeros pares:”);
FOR (I=0; I
{
IF (VALORES [I]%2==0)
{
PRINT VALORES [I];
}}
PRINT ();
PRINT (“suma de los numeros pares”, sumapar)
PRINT (“NUMEROS IMPARES :”)
FOT ( I=0; I
{
IF (VALORES [I] %2==1)
{
PRINT (VALORES [I]);
}}
PRINT ();
PRINT (“suma de numeros impares”, sumaimpar);
FIN
CODIGO EN CONSOLA
int[] temp = new int[8];
int suma = 0, I, P;
Console.WriteLine("Introduce los siguientes valores enteros:");
for (I = 0; I < 8; I++)
{
Console.Write("Dato {0}:", I);
temp[I] = int.Parse(Console.ReadLine());
suma += temp[I];
}
P = suma / 8;
Console.WriteLine("\nLista de los 8 valores enteros:");
for (I = 0; I < 8; I++)
{
Console.WriteLine("\t\t\t\t" + temp[I]);
}
Console.WriteLine("\nPromedio = {0}", P);
Console.ReadKey();
_consola(img).jpg)
CODIGO EN WINDOWS:
int[] temp;
int I, suma, P;
public Form1()
{
InitializeComponent();
temp = new int[8];
I = suma = P = 0;
listBox1.Items.Add("NUMEROS ENTEROS");
}
private void Form1_Load(object sender, EventArgs e)
{
}
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();
}

No hay comentarios:
Publicar un comentario