当我先画完第二个Newton图之后,再单击其他按钮,为什么我的按钮会出现多个默认按钮,点击并不响应,附件里有我的源代码,希望牛人指点,急!
解决方案 »
- 如何写如下正则表达式?
- asp.net(C#)如何设置label的行高?
- 在软件上怎样加广告啊
- 请教控件 progressBar1和trackBar1问题。
- 菜鸟问题!如何实现按回车键就可以触击button
- 一个TextBox 的Name为txtSite,一个string变量赋值,我如何通过这个变量,对TextBox控件的Text属性进行赋值操作
- 我用自己的程序打开了IE浏览器,怎么把那个浏览窗口变为当前窗口?
- 一个简单的问题
- 那位有datagrid和sql或是access相关连的实例源程序呀?
- C#高手,请进,在线等待!!!!
- DataGridView 多选单元格 操作
- Object reference not set to an instance of an object.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace exp1
{
public partial class solution1 : Form
{
public solution1()
{
InitializeComponent();
}
public double[] x1 ={1,2,3,4,5,6,7};
public double[] y1 ={0.368,0.135,0.050,0.018,0.007,0.002,0.001};
public int showpic1=0;
public int showpic2 = 0;
private void button1_Click(object sender, EventArgs e)
{
double temp;
temp = p(0.596);
textBox1.Text = temp.ToString();
}
public double p(double xx)
{
double[] x ={ 0.4, 0.55, 0.65, 0.80, 0.95, 1.05 };
double[] y ={ 0.41075, 0.57815, 0.69675, 0.90, 1.00, 1.25382 };
int i, k;
double pp = 0, m1, m2;
for (i = 0; i <= 5; i++)
{
m1 = 1;
m2 = 1;
for (k = 0; k <= 5; k++)
if (k != i)
{
m1 *= xx - x[k];
m2 *= x[i] - x[k];
}
pp += y[i] * m1 / m2;
}
return pp;
}
public double jc(int k)
{
int i,j;
double s=0,m;
for(i=0;i<=k;i++)
{
for(m=1,j=0;j<=k;j++)
if(j!=i)m*=x1[i]-x1[j];
s+=y1[i]/m;
}
return s;
}
public double newton(double X)
{
double nt = y1[0], m;
int i, j;
for (i = 1; i <= 6; i++)
{
for (m = 1, j = 0; j <= i - 1; j++)
m *= X - x1[j];
nt += jc(i) * m;
}
return nt;
} private void button2_Click(object sender, EventArgs e)
{
double temp;
temp = p(0.99);
textBox1.Text = temp.ToString();
} private void button4_Click(object sender, EventArgs e)
{
double temp;
temp = newton(6.15);
textBox2.Text = temp.ToString();
} private void button3_Click(object sender, EventArgs e)
{
double temp;
temp = newton(1.8);
textBox2.Text = temp.ToString();
} private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
if (showpic1 == 1)
{
float[] x2 = new float[50];
float[] y2 = new float[50]; for (int i = 0; i < 50; i++)
{
if (i == 0)
{
x2[i] = 0;
y2[i] = (float)p(x2[i]);
}
else
{
x2[i] = x2[i - 1] + 0.04f;
y2[i] = (float)p(x2[i]);
}
} pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
CurvePaint cp = new CurvePaint();
cp.XkeduCount = 10;
cp.YkeduCount = 10;
cp.XvalueStrMoveleft = 15;
pictureBox1.Image = cp.drawCurve(x2, y2, "Lagrange多项式", "Xi", "Yi");
}
} private void button5_Click(object sender, EventArgs e)
{
showpic1 = 1;
pictureBox1.Invalidate();
pictureBox1.Update();
}
private void pictureBox2_Paint(object sender, PaintEventArgs e)
{
if (showpic2 == 1)
{
float[] x3 = new float[10];
float[] y3 = new float[10]; for (int i = 0; i < 10; i++)
{
if (i == 0)
{
x3[i] = 0;
y3[i] = (float)newton(x3[i]);
}
else
{
x3[i] = x3[i - 1] + 1.0f;
y3[i] = (float)newton(x3[i]);
}
} pictureBox2.SizeMode = PictureBoxSizeMode.Zoom;
CurvePaint cp = new CurvePaint();
cp.XkeduCount = 10;
cp.YkeduCount = 10;
cp.XvalueStrMoveleft = 15;
pictureBox2.Image = cp.drawCurve(x3, y3, "Newton多项式", "Xi", "Yi");
}
} /* private void button6_Click(object sender, EventArgs e)
{
showpic2 = 1;
pictureBox2.Invalidate();
pictureBox2.Update();
}*/ private void solution1_Load(object sender, EventArgs e)
{ } private void button6_Click(object sender, EventArgs e)
{
showpic2 = 1;
pictureBox2.Invalidate();
pictureBox2.Update(); }
}
}