| 网站首页 | 业界新闻 | 群组 | 人才 | 技术文章 | 下载频道 | 博客 | 代码贴 | 编程论坛
绝地游戏外挂辅助教学千里之行 始于足下
共有 2263 人关注过本帖
标题:求大神帮忙解答问题,C#编程画圆,出现下列问题,怎么破?
只看楼主 收藏
mjh113439122
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2015-10-6
结帖率:100%
  已结贴   问题点数:20  回复次数:5   
求大神帮忙解答问题,C#编程画圆,出现下列问题,怎么破?
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)”: 并非所有的代码路径都返回值
搜索更多相关主题的帖子: public  private  double  
2015-10-06 18:08
yhlvht
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:36
帖 子:695
专家分:4405
注 册:2011-9-30
  得分:20 
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;
        }
    }
}
2015-10-06 23:55
mjh113439122
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2015-10-6
  得分:0 
画不出来圆是为什么那?
2015-10-07 12:40
tlliqi
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:204
帖 子:15455
专家分:65956
注 册:2006-4-27
  得分:0 
回复 3楼 mjh113439122
试试楼上的
2015-10-07 18:29
mjh113439122
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2015-10-6
  得分:0 
试了,还是不行
附件: 您没有浏览附件的权限,请 登录注册
2015-10-07 18:33
yhlvht
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:36
帖 子:695
专家分:4405
注 册:2011-9-30
  得分:0 
这个程序一共画了三个椭圆,坐标分别是picturebox1相对左上角坐标的10,10    20,10   10,20
正常画出来三个椭圆是相交的,DrawEllipse方法的第4,5个参数分别表示宽和高,因为传入的参数分别都为r1,r2,r3,宽高一样,所以画出来是圆形
但是hanshu类的F方法,也就是计算宽高的这个方法,那个公式没看明白,经测试,传入的大多数字,计算后宽高(半径)几乎都小于0或接近0,所以看不到
你在三个textbox内都输入-100,即传入-100参数给F方法,能得到宽高(半径)为26.41401931439983,可以看到画出来的圆(仅测试而已)
2015-10-07 23:41







关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.079998 second(s), 7 queries.
Copyright©2004-2017, BCCN.NET, All Rights Reserved