inicio
double[] pendiente = 17.24, 26.63, 5.94, 33.92, 3.71, 32.84, 35.93, 18.24, 6.92
double mayor = 0, menor = 0
read I = 0
mayor = pendiente[0]
menor = pendiente[0]
for (I = 1; I
Escriba un programa que almacene los siguientes valores en un arreglo llamado pendientes: 17.24,25.63,5.94,33.92,3.71,32.84,35.93,18.24,6.92. el programa debe localizar los valores maximos y minimos del arreglo.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
double[] pendiente = { 17.24, 26.63, 5.94, 33.92, 3.71, 32.84, 35.93, 18.24, 6.92 };
double mayor = 0, menor = 0;
int I = 0;
mayor = pendiente[0];
menor = pendiente[0];
for (I = 1; I <> mayor)
{
mayor = pendiente[I];
}
}
for (I = 0; I <>
{
if (pendiente[I] < menor =" pendiente[I];">
} }
Console.WriteLine("el valor maximo es {0}: ", mayor);
Console.WriteLine("el valor minimo es {0}: ", menor);
Console.ReadLine(); } } }
ARREGLO LLAMADO PENDIENTES (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
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
double[] pendiente = { 17.24, 25.63, 5.94, 33.92, 3.71,35.93, 18.24, 6.92,32.1 };
double mayor = pendiente[0];
double menor = pendiente[0];
int i;
listBox1.Items.Add("Pendientes:");
for (i = 0; i <= 8; i = i + 1) { listBox1.Items.Add(pendiente[i]); if (pendiente[i] > mayor)
{
mayor = pendiente[i];
}
if (pendiente[i] < menor =" pendiente[i];" text =" (" text =" (">
No hay comentarios:
Publicar un comentario