inicio
temp[10] int
total=0 int
I=0 int
Prom=0 int
Print "Introduce los siguientes elementos"
for (I=0 to 9 step I=I+1)
{
Print "temp", I
Read temp[I]
total=total + temp[I]
}
Prom = total/10
for (I=0 to 9 step I=I+1)
{
print=temp[I]
}
Print "Promedio", Prom
fin
CONSOLA
namespace practica9problema1
{
class Program
{
static void Main(string[] args)
{
int[] temp = new int[10];
int total = 0;
int I=0;
double promedio=0;
Console.WriteLine("Introduce los siguientes elementos:");
for (I = 0; I < 10; I = I + 1)
{
Console.WriteLine("\nTemperatura{0}:", I+1);
temp[I] = int.Parse(Console.ReadLine());
total = total + temp[I];
}
promedio = total / 10;
for (I = 0; I < 10; I = I + 1)
{
Console.WriteLine("\n{0}", temp[I]);
}
Console.WriteLine("\nPromedio es:{0}", promedio);
Console.ReadKey();
}
}
}
VISUAL
namespace practica9problema1vis
{
public partial class Form1 : Form
{
int[] temp;
int I, total, prom;
public Form1()
{
InitializeComponent();
temp=new int[10];
I = 0;
total = 0;
prom = 0;
}
private void button1_Click(object sender, EventArgs e)
{
if (I < 10)
{
temp[I] = int.Parse(textBox1.Text);
total = total + temp[I];
listBox1.Items.Add("Elemento" + I + " : " + temp[I]);
I++;
textBox1.Clear();
textBox1.Focus();
}
if (I == 10)
{
textBox1.Enabled = false;
button1.Enabled = false;
}
}
private void label1_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
prom = total / 10;
listBox1.Items.Add("Promedio =" + prom);
}
private void button3_Click(object sender, EventArgs e)
{
Close();
}
private void button4_Click(object sender, EventArgs e)
{
I = 0;
textBox1.Enabled= true;
button1.Enabled= true;
listBox1.Items.Clear();
}
}
}

No hay comentarios:
Publicar un comentario