miércoles, 9 de diciembre de 2009

EXTRAS PRACTICAS 13 CONSOLA Y WINDOWS MEDIO ARMONICO

SPEUDOCODIGO

int[] ex = { 12, 6, 5, 32, 7, 4, 12, 88, 42, 2 };

int suma = 0, i;

double arm;

for (i = 0 to i <= 5 step i = i + 1)

{

suma = suma + ex[i];

}

arm = 10.0 / suma;

print"SUMA= " + suma;

print"el medio armonico es: " + arm;

FIN

consola

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace examne_3_m_armonico

{

class Program

{

static void Main(string[] args)

{

int[] ex = { 12, 6, 5, 32, 7, 4, 12, 88, 42, 2 };

int suma = 0, i;

double arm;

for (i = 0; i <= 5; i = i + 1)

{

suma = suma + ex[i];

}

arm = 10.0 / suma;

Console.WriteLine("\tSUMA= " + suma);

Console.WriteLine("\tel medio armonico es: " + arm);

Console.ReadLine();

}

}

}



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 examne_3_m_armonico_visual

{

public partial class Form1 : Form

{

int[] ex = { 12, 6, 5, 32, 7, 4, 12, 88, 42, 2 };

int suma = 0, i;

double arm;

public Form1()

{

InitializeComponent();

suma = 0;

}

private void button1_Click(object sender, EventArgs e)

{

for (i = 0; i <= 5; i = i + 1)

{

suma = suma + ex[i];

}

arm = 10.0 / suma;

listBox1.Items.Add("SUMA= " + suma);

listBox1.Items.Add("el medio armonico es:");

listBox1.Items.Add(arm);

}

private void button2_Click(object sender, EventArgs e)

{

listBox1.Items.Clear();

}

private void button3_Click(object sender, EventArgs e)

{

Close();

}

}

}


No hay comentarios:

Publicar un comentario