martes, 20 de octubre de 2009

Practica #7-4 (Suma de Pares e Impares) .C


PSEUDOCODIGO

INICIO



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 valor entero ";
READ Valores[I]
if (valores[I] % 2 == 0)
{
sumapar += valores[I];
}
else
{
sumaimpar += valores[I];
}
}
PRINT"Numeros Pares ";
for (I = 0; I <>
{
if (valores[I] % 2 == 0)
{
PRINT( valores[I]);
}
}
Console.WriteLine();
PRINT"La suma de los numeros pares es{0} ", sumapar;
PRINT("Numeros impares ");
for (I = 0; I <>
{
if (valores[I] % 2 == 1)
{
PRINT("{0} ", valores[I];
}
}

PRINT"La suma de numeros impares es {0} ", sumaimpar;
if (sumapar > sumaimpar)
{
PRINT"La suma mayor es par:{0}", sumapar;
}
else
{
PRINT"\nLa suma mayor es impar:{0} ", sumaimpar;
}
FINAL




CONSOLA






int N;
int[] valores;
Console.Write("Introduce numero de elementos \n ");
N = int.Parse(Console.ReadLine());
valores = new int[N];
int I;
int sumapar = 0;
int sumaimpar = 0;
for (I = 0; I < 2 ="=" i =" 0;" 2 ="=" i =" 0;" 2 ="="> sumaimpar)
{
Console.WriteLine("\nLa suma mayor es par:{0} ", sumapar);
}
else
{
Console.WriteLine("\nLa suma mayor es impar:{0} ", sumaimpar);
}


Console.ReadKey();

VISUAL

int n, suma, num, num1, mayor=0, menor=0;
double suma1;suma = 0;suma1 = 0;
double c=0 ;
n = int.Parse(textBox1.Text);
for (num = 1; num <= n; num = num + 2) { suma = suma + num; } for (num1 = 2; num1 <= n; num1 = num1 + 2) { suma1 =suma1 + num1; } c = c + 1;if (suma <>
{textBox2.Text = (suma.ToString());textBox3.Text = (suma1.ToString());textBox4.Text = (suma1.ToString());
for (c = 2; c <= n; c = c + 2) { listBox1.Items.Add(c); }} else{textBox2.Text = (suma.ToString());textBox3.Text = (suma1.ToString());textBox4.Text = (suma.ToString()); for (c = 1; c <= n; c = c + 2) {listBox1.Items.Add(c); }}} private void button2_Click(object sender, EventArgs e) {textBox2.Text="";textBox3.Text = "";textBox4.Text = "". } }}


No hay comentarios:

Publicar un comentario