pseudocodigo.
Real[] resistencia ={16,27,39,56,81};
Real[] corriente = new int [5];
Real[] potencia = new int[5];
Real total = 0, I = 0;
for (I = 0 TO 4 STEP I=I+1)
{
print("Introduce corriente",I);
Read corriente[I]
potencia[I] = resistencia[I] * (corriente[I] * corriente[I]);
total = total + potencia[I];
}
print( Resistencia Corriente Potencia );
for (I = 0 TO 4 STEP I=I+1)
{
print(, resistencia[I], corriente[I], potencia[I]);
}
print("Total + total);
FINAL
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int[] resistencia = { 16, 27, 39, 56, 81 };
int[] corriente = new int[5];
int[] potencia = new int[5];
int total = 0, I = 0;
for (I = 0; I <= 4; I++)
{ Console.WriteLine("Introduce corriente", I);
corriente[I] = int.Parse(Console.ReadLine());
potencia[I] = resistencia[I] * (corriente[I] * corriente[I]);
total = total + potencia[I];
}
Console.WriteLine(" Resistencia\tCorriente\tPotencia");
for (I = 0; I <= 4; I++)
{ Console.WriteLine(" {0}\t\t{1}\t\t{2}", resistencia[I], corriente[I], potencia[I]);
} Console.WriteLine("en total= " + total);
Console.ReadKey();
} } }
PRACTICA 10.2 ARREGLOS, RESISTENCIA, CORRIENTE Y POTENCIA (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[] resistencia = { 16, 27, 39, 56, 81 };
int[] corriente = new int[5];
int[] potencia = new int[5];
int total = 0, I = 0;
public Form1()
{
InitializeComponent();
total = 0;
listBox1.Items.Add("RESISTENCIA CORRIENTE POTENCIA");
}
private void button1_Click(object sender, EventArgs e)
{
if (I < 5)
{
textBox1.Focus();
corriente[I] = int.Parse(textBox1.Text);
potencia[I] = resistencia[I] * (corriente[I] * corriente[I]);
textBox1.Clear();
total = total + potencia[I];
listBox1.Items.Add(resistencia[I].ToString() + "\t\t" + corriente[I].ToString() + "\t\t" + potencia[I].ToString());
I++;
}
else
{
button1.Enabled = false;
}
}
private void button2_Click_1(object sender, EventArgs e)
{
textBox2.Text = (total.ToString());
}
private void button3_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
textBox1.Clear();
textBox2.Clear();
textBox1.Enabled =true;
button1.Enabled = true;
}
private void button4_Click(object sender, EventArgs e)
{
Close();
}
}
}
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario