![]() |
#2
yhlvht2015-10-06 23:55
namespace WindowsFormsApplication1
{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void textBox1_TextChanged(object sender, EventArgs e) { } private void textBox2_TextChanged(object sender, EventArgs e) { } private void textBox3_TextChanged(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { hanshu qiangdu1 = new hanshu(); int x = Convert.ToInt32(textBox1.Text); double r1 = qiangdu1.F(x); hanshu qiangdu2 = new hanshu(); int m = Convert.ToInt32(textBox2.Text); double r2 = qiangdu1.F(m); hanshu qiangdu3 = new hanshu(); int n = Convert.ToInt32(textBox3.Text); double r3 = qiangdu1.F(n); Graphics gra = this.pictureBox1.CreateGraphics(); Pen pen = new Pen(Color.Pink); gra.DrawEllipse(pen, 10, 10, Convert.ToInt32(r1), Convert.ToInt32(r1)); gra.DrawEllipse(pen, 20, 10, Convert.ToInt32(r2), Convert.ToInt32(r2)); gra.DrawEllipse(pen, 10, 20, Convert.ToInt32(r3), Convert.ToInt32(r3)); } } class hanshu { public double F(int x) { const double a1 = 30.58; const double b1 = -110.7; const double c1 = 27.96; double f = a1 * Math.Exp(-((x - b1) / c1) * ((x - b1) / c1)); return f; } } } |
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
class hanshu
{
public double F(int x)
{
const double a1=30.58;
const double b1=-110.7;
const double c1=27.96;
double f=a1*Math.Exp(-((x-b1)/c1)*((x-b1)/c1));
}
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
hanshu qiangdu1=new hanshu();
int x=Convert.ToInt32(textBox1.Text);
double r1=qiangdu1.F(x);
hanshu qiangdu2=new hanshu();
int m=Convert.ToInt32(textBox2.Text);
double r2=qiangdu1.F(m);
hanshu qiangdu3=new hanshu();
int n=Convert.ToInt32(textBox3.Text);
double r3=qiangdu1.F(n);
Graphics gra = this.pictureBox1.CreateGraphics();
Pen pen = new Pen(Color.Pink);
gra.DrawEllipse(pen, 10, 10, Convert.ToInt32(r1), Convert.ToInt32(r1));
gra.DrawEllipse(pen, 20, 10,Convert.ToInt32(r2), Convert.ToInt32(r2));
gra.DrawEllipse(pen, 10, 20,Convert.ToInt32(r3), Convert.ToInt32(r3));
}
}
}
错误 应输入 class、delegate、enum、interface 或 struct
错误 应输入类型、命名空间定义或文件尾
错误 “WindowsFormsApplication1.Form1.hanshu.F(int)”: 并非所有的代码路径都返回值