miércoles, 28 de octubre de 2009

Practica 8.2 b) y c) Visual

Pseudocódigo

int[] emax = new int[10]
int I, mayor
Print ("Introduce un numero entero")
Read emax[0]
mayor = emax[0]
for (I = 1; I < 10; I++)
{
Print ("Introduce dato []", I)
Read emax[I]
if (emax[I] > mayor)
{
mayor = emax[I]
}
}
Print ("Listado de 10 nuemros enteros")
for (I = 0; I < 10; I++)
{
Print (emax[I]);
}
Raed ("El valor maximo es ", mayor)
Fin













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 PRACTICA_8_2
{
public partial class Form1 : Form
{
int[] Emax = new int[10];
int I, mayor, pos = 0;

public Form1()
{
InitializeComponent();
I = 0;
listBox1.Items.Add("Valores enteros:");

}

private void Form1_Load(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
if (I <>
{


Emax[I] = int.Parse(textbox1.Text);
if (I == 0)
{


mayor = Emax[0];
}
textbox1.Clear();
textbox1.Focus();

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 button3_Click(object sender, EventArgs e)
{
textbox1.Clear();
listBox1.Items.Clear();
button1.Enabled = true;

}

private void button4_Click(object sender, EventArgs e)
{
Close();
}

private void button2_Click_1(object sender, EventArgs e)
{

MessageBox.Show("El valor maximo es: " + mayor.ToString() + "\nPosicion numero: " + pos.ToString());
}
}
}

No hay comentarios:

Publicar un comentario