jueves, 22 de abril de 2010

practica 10

PRACTICA 10_1 CONSOLA
sing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int []resistencia=new int[5]{16,27,39,56,81};
double[]corrinete=new double[5];
double[]potencia=new double[5];
int i;
double suma;
suma = 0;
Console.WriteLine("Introduce valor de corrientes");
for(i=0;i<5;i=i+1) suma="suma+potencia[i];" i="0;i<5;i="i+1)" total= "+suma); Console.ReadKey(); } } } 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[] resistencia;
double[] corriente;
double[] potencia ;
int i;
double suma;
public Form1()
{


InitializeComponent();
resistencia=new int[5]{16,27,39,56,81};
corriente = new double[5];
potencia = new double[5];
suma = 0;
i = 0;
listBox1.Items.Add("Resistencia corriente potencia");





}

private void button1_Click(object sender, EventArgs e)
{
if (i <= 4)
{
corriente[i] = double.Parse(textBox1.Text);
potencia[i] = resistencia[i] * Math.Pow(corriente[i],2);
suma = suma + potencia[i];
listBox1.Items.Add(" " + resistencia[i] + " " + corriente[i] + " " + potencia[i]);


i = i + 1;
textBox1.Clear();
textBox1.Focus();

}
if (i == 4)
{
textBox1.Enabled = false;

button1.Enabled = false;

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

}


private void button2_Click(object sender, EventArgs e)
{
textBox1.Enabled = true;
button1.Enabled = true;

listBox1.Items.Clear();
}
}
}

PRACTICA 10_2 CONSOLA
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
double[] pendientes ={17.24,25.63,5.94,33.92,3.71,31.84,45.90,35.99,18.44,6.92,12.2,29.45,13.89,5.21,2.56,8.77,23.99,7.23,31.56};
double max;
max=pendientes[0];

int i;
i = 0;
double pmax;
pmax =0;


double min;
min=pendientes[0];
int pmin=0;

for (i = 1; i < i =" i"> max)
{
max = pendientes[i];
pmax = i;
}
if (pendientes[i] < min =" pendientes[i];" pmin =" i;" i =" 1;" i =" i" mayor= "+max + " menor= " +min+ " style="color: rgb(255, 153, 0);">PRACTICA 10_2 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
{
double[] pendiente;
double max;
int pmax;
double min;
int pmin;
int i;
public Form1()
{


InitializeComponent();

pendiente = new double[19] { 17.24, 25.63, 5.94, 33.92, 3.71, 31.84, 45.90, 35.99, 18.44, 6.92, 12.2, 29.94, 13.89, 5.21, 2.65, 8.77, 23.99, 7.23, 31.56 };
max = pendiente[0];
pmax = 0;
min = pendiente[0];
pmin = 0;
i = 0;

}

private void button1_Click(object sender, EventArgs e)
{
{
for (i = 1; i < i =" i">
{
if (pendiente[i] > max)
{
max = pendiente[i];
pmax = i;
}
if (pendiente[i] <>
{
min = pendiente[i];
pmin = i;
}
}
listBox1.Items.Add("Pendientes");
for (i = 1; i < i =" i">
{
listBox1.Items.Add( " " + pendiente[i]);

}

listBox1.Items.Add("Pendiente mayor " + max);
listBox1.Items.Add("En la posici¢n " + pmax);
listBox1.Items.Add("Pendiente menor " + min);
listBox1.Items.Add("En la posici¢n " + pmin);


}


}

private void button2_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();

}
}
}



No hay comentarios:

Publicar un comentario