inicio
int n, valor, M, m, c = 1
print "INTRODUCE LA CANTIDAD DE NUMEROS"
Read n
print "INTRODUCE UN VALOR ENTERo"
Read valor
M=valor; m=valor; c=1
while(M>m)
{
M=valor;
} if(valor>M)
{
m=valor;
}
c = c + 1
}
print("EL DATO MAYOR ES ,M)
print("EL DATO MENOR ES ",m
}fin
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n, valor, M, m, c = 1;
Console.WriteLine("INTRODUCE LA CANTIDAD DE NUMEROS");
n = int.Parse(Console.ReadLine());
Console.WriteLine("INTRODUCE UN VALOR ENTERO__");
valor = int.Parse(Console.ReadLine());
M=valor;
m=valor;
c=1;
while(M
{
M=valor;
}
if(valor>M)
m=valor;
}
c = c + 1;
}
Console.WriteLine("EL DATO MAYOR ES:{0}",mayor);
Console.WriteLine("EL DATO MENOR ES:{0}",menor);
Console.ReadKey();
}
}
}
NUMERO MAYOR, NUMERO MENOR.(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
int N, valor, may, men, c = 1;
public Form1()
{InitializeComponent();
}private void button1_Click(object sender, EventArgs e)
{
N = int.Parse(textBox1.Text);
valor=int.Parse(textBox2.Text);
textBox2.Focus();
textBox2.Clear();
if (c <= N)
{listBox1.Items.Add(valor);
if (valor > may)
{may = valor;
}
if (valor <>
{men = valor;
}
c = c + 1;}
else{textBox2.Clear();
textBox2.Enabled = false;
button1.Enabled = false;
}}private void button2_Click(object sender, EventArgs e)
{label3.Text = "El dato mayor es:" + may.ToString();label4.Text = "El dato menor es:" + men.ToString();
}
No hay comentarios:
Publicar un comentario