Practica 8.2
Author: Moises
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 Formula_visual
{
public partial class Form1 : Form
{
Arreglo H = new Arreglo();
Arreglo F = new Arreglo();
int I=0;
int Num;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
textBox3.Enabled = false;
label1.Text = "H[" + (I + 1) + "]:";
label2.Text = "F[" + (I + 1) + "]:";
}
private void button2_Click(object sender, EventArgs e)
{
double dat1, dat2;
Num = int.Parse(textBox3.Text);
if (I < Num)
{
label1.Text = "H[" + (I + 2) + "]:";
dat1 = double.Parse(textBox1.Text);
H.AsignarDato(I, dat1);
label2.Text = "F[" + (I + 2) + "]:";
dat2 = double.Parse(textBox2.Text);
F.AsignarDato(I, dat2);
I++;
textBox2.Clear();
textBox1.Clear();
}
if (I == Num)
{
double s = 0.0;
for (I = 0; I < Num; I++)
{
s = s + H.ObtenerDato(I) * F.ObtenerDato(I);
}
double Numerador = Num * s - H.SumaDatos(Num) * F.SumaDatos(Num);
double D = (Num * H.SumaCuadrada(Num) - H.SumaCuadrada(Num)) * (Num * F.SumaCuadrada(Num) - F.SumaCuadrada(Num));
double Denominador = Math.Sqrt(D);
double r = Numerador / Denominador;
label3.Visible = true;
label3.Text = ("El Valor de R es: " + r);
}
}
}
}