int N
int[] valores
print "Introduce numero de elementos "
Read Nvalores = new int[N]
int I
int sumapar = 0
int sumaimpar = 0
for (I = 0 to I step I++)
{
print "Introduce valor entero "
Read Valores[I] if (valores[I] % 2 == 0)
{
sumapar += valores[I]
}
else
{
sumaimpar += valores[I];
}}
print(" ");
for (I = 0;I
{
if (valores[I] % 2 == 0)
{
print( valores[I])
}}
print"{0} ", sumapar
print "Numeros impares "
for (I = 0; I
if (valores[I] % 2 == 1)
{
print "{0} ", valores[I]
}}
print" {0} ", sumaimpar
if (sumapar > sumaimpar)
{
print":{0}", sumapar)
}
else
{
print":{0} ", sumaimpar
}final
A continuacion el ejecutable o programa para este ejercicio.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int N;
int[] valores;
Console.Write("INTRODUCE NUMEROS DE ELEMENTOS \n ");
N = int.Parse(Console.ReadLine());
valores = new int[N];
int I;
int sumapar = 0;
int sumaimpar = 0;
for (I = 0; I
Console.Write("MUNERO ENTERO__");
valores[I] = int.Parse(Console.ReadLine());
if (valores[I] % 2 == 0)
{
sumapar = valores[I];
}
else
{
{sumaimpar += valores[I];
}}
Console.WriteLine("Numeros Pares ");
for (I = 0; I <>
{
if (valores[I] % 2 == 0)
{
Console.WriteLine("valores{0} ", valores[I]);
}}
Console.WriteLine();
Console.WriteLine("\n\nLa suma de los numeros pares es{0} ", sumapar);
Console.WriteLine("Numeros impares ");
for (I = 0; I < 2 ="=">
{
Console.Write("{0} ", valores[I]);
}}
Console.WriteLine();
Console.WriteLine("\n\nLa suma de numeros impares es {0} ", sumaimpar);
if (sumapar > sumaimpar)
{Console.WriteLine("\nLa suma mayor es par:{0} ", sumapar);
}
else
{Console.WriteLine("\nLa suma mayor es impar:{0} ", sumaimpar);
}Console.ReadKey();
SUMA DE PARES Y SUMA DE MAYORE IMPAR.
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
{
private void button1_Click(object sender, EventArgs e)
{
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