sábado, 24 de octubre de 2009

PRACTICA 6 PROBLEMA 1




namespace practica_6._1_consola
{
class Program
{
static void Main(string[] args)
{
double n, i, factor = 1.0;
Console.WriteLine("\n\nINTRODUCE EL VALOR DEL FACTORIAL");
n = double.Parse(Console.ReadLine());
for (i = n; i >= 1; i--)
{
factor = factor * i;
}
Console.WriteLine("\n\nEL FACTORIAL ES: {0}", factor);
Console.ReadLine();

PRACTICA EN WINDOWS


namespace practica_6._1_windows
{
public partial class Form1 : Form
{
double factor, n, i;
public Form1()
{
factor = 1.0;
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
double n, i, factor = 1.0;
n = int.Parse(textBox1.Text);
for (i =n; i >= 1; i--)
for (i = n; i >= 1; i--)
{
factor = factor * i;
}
textBox2.Text = factor.ToString();
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
}
private void button3_Click(object sender, EventArgs e)
{
Close();
}
private void Form1_Load(object sender, EventArgs e)

No hay comentarios:

Publicar un comentario