20091215

PRACTICA 11. 1 VALOR MAXIMO ARREGLO BIDIMENSIONAL(visual)


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
{
public partial class Form1 : Form
{
int posc, posr, mayor;
int r, c;
int[,] numeros = { { 16, 22, 99, 4, 18 }, { -258, 4, 101, 5, 98 }, { 105, 6, 15, 2, 45 }, { 33, 88, 72, 16, 3 } };

public Form1()
{
InitializeComponent();
posc = posr = mayor = 0;
listBox1.Items.Add("los elementos de la matriz son :");
}

private void button1_Click(object sender, EventArgs e)
{
for (r = 0; r <= 3; r++)
{
for (c = 0; c <= 4; c++)
{
if (numeros[r, c] > mayor)
{
mayor = numeros[r, c];
posc = c + 1;
posr = r + 1;


}
else
{
}
listBox1.Items.Add("en el renglon:" + "\t" + posr + "\t" + "en la columna" + "\t" + posc + "\t" + "el numero" +"\t"+ numeros[r, c]);

}

}
listBox1.Items.Add("el dato mayor en el arrego es:" + mayor);
listBox1.Items.Add("en el renglon:"+"\t" + posr);
listBox1.Items.Add("en la columna:" + "\t" + posc);

}

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