Pseudocodigo.
REAL[,] voltajes=new double[3,5];
REAL c1 =0,c2=0,r=0,c=0,suma1=0,suma2=0;
for (r = 0 TO 3 r=r+1)
{
for (c = 0 TO 5; c= c+1)
{
PRINT "Voltajes [{0},{1}] : ", r, c
READ voltajes[r, c]
}
}
for (r = 0 TO 3; r=r+1)
{
for (c = 0 TO 5; c=c+1)
{
if (voltajes[r, c] < 60)
{
c1 = c1 + 1;
}
else
{
if (voltajes[r, c] >= 60)
{
c2 = c2 + 1;
}
}
}
}
PRINT "No. de Voltajes <60>=60 : {1}", c1,c2);
final .
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
double[,] voltajes = new double[3, 5];
int SUMA1 = 0, SUMA2 = 0, r = 0, c = 0;
for (r = 0; r < 3; r++)
{ for (c = 0; c < 5; c++)
{ Console.Write("Voltajes [{0},{1}] : ", r, c);
voltajes[r, c] = double.Parse(Console.ReadLine());
} }
for (r = 0; r < 3; r++)
{ for (c = 0; c < 5; c++)
{ if (voltajes[r, c] < 60)
{ SUMA1 = SUMA1 + 1;
} else { if (voltajes[r, c] >= 60)
{
SUMA2 = SUMA2 + 1;
}}}}
Console.WriteLine("\n VOLTAJES MENORES DE 60 : {0}\n\n VOLTJES MAYORES DE 60 : {1}", SUMA1, SUMA2);
Console.ReadKey();
}
}
}
PRACTICA 10.3 ARREGLO BIDIMENSIONAL. (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[,] voltaje = new int[3, 5];
int resistencia = 0;
int corriente = 0;
int c1 = 0, c2 = 0;
public Form1()
{
InitializeComponent();
listBox1.Items.Add("");
}
private void button1_Click(object sender, EventArgs e)
{if (resistencia < 3)
{ if (corriente < 5)
{ voltaje[resistencia, corriente] = int.Parse(textBox1.Text);
listBox1.Items.Add("Voltaje [" + resistencia.ToString() + "," + corriente.ToString() + "] : " + voltaje[resistencia, corriente].ToString());
corriente++;
textBox1.Clear();
}
else
{
resistencia++;
corriente = 0;
}
}
}
private void button2_Click_1(object sender, EventArgs e)
{
for (resistencia = 0; resistencia < 3; resistencia++)
{
for (corriente = 0; corriente < 5; corriente++)
{
if (voltaje[resistencia, corriente] < 60)
{
c1 = c1 + 1;
}
else
{if (voltaje[resistencia, corriente] >= 60)
{
c2 = c2 + 1;
}
}
}
}
textBox2.Text = ("Numero de Voltajes <60 es: " + c1.ToString());
textBox3.Text = ("Numero de Voltases >=60 es: " + c2.ToString());
}
private void button3_Click_1(object sender, EventArgs e)
{ textBox1.Clear();
listBox1.Items.Clear();
textBox2.Clear();
textBox3.Clear();
}
private void button4_Click(object sender, EventArgs e)
{
Close();
}
}
}
20091117
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario