一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

asp.net(c#)復(fù)數(shù)類(lèi)(復(fù)數(shù)加減乘除四則運(yùn)算)

我的一個(gè)Java作業(yè),把它改寫(xiě)成ASP.NET(c#)了
復(fù)制代碼 代碼如下:
protected void Page_Load(object sender, EventArgs e)
    {
        complex complex_a = new complex(1.0, 1.0);
        complex complex_b = new complex(2.0, 2.0);
        Response.Write("加法運(yùn)算結(jié)果:" + complex_a.complex_add(complex_b).ToString() + "<br />");
        Response.Write("減法運(yùn)算結(jié)果:" + complex_a.complex_minus(complex_b).ToString() + "<br />");
        Response.Write("乘法運(yùn)算結(jié)果:" + complex_a.complex_multi(complex_b).ToString() + "<br />");
        Response.Write("除法運(yùn)算結(jié)果:" + complex_a.complex_divide(complex_b).ToString());
    }
    //design by 阿會(huì)楠 來(lái)自:搜索吧 sosuo8.com
    public class complex
    {
        //復(fù)數(shù)中的實(shí)部
        private double complex_real;
        //復(fù)數(shù)中的虛部
        private double complex_imagin;

        //構(gòu)造函數(shù)
        public complex(double r, double i)
        {
            complex_real = r;
            complex_imagin = i;
        }

        //重寫(xiě)ToString()方法 
        public override string ToString()
        {
            return this.complex_real + "+" + this.complex_imagin + "i";
        }

        //復(fù)數(shù)加法運(yùn)算
        public complex complex_add(complex c)
        {
            //取得加法運(yùn)算后的實(shí)部
            double complex_real = this.complex_real + c.complex_real;

            //取得加法運(yùn)算后的虛部
            double complex_imagin = this.complex_imagin + c.complex_imagin;

            //返回一個(gè)復(fù)數(shù)類(lèi)
             return new complex(complex_real,complex_imagin);
        }

        //復(fù)數(shù)減法運(yùn)算
        public complex complex_minus(complex c)
        {
            //取得減法運(yùn)算后的實(shí)部
            double complex_real = this.complex_real - c.complex_real;

            //取得減法運(yùn)算后的虛部
            double complex_imagin = this.complex_imagin - c.complex_imagin;

            //返回一個(gè)復(fù)數(shù)類(lèi)
            return new complex(complex_real, complex_imagin);
        }

        //乘法運(yùn)算
        public complex complex_multi(complex c)
        {
            //取得乘法運(yùn)算后的實(shí)部
            double complex_real = this.complex_real * c.complex_real - this.complex_imagin * c.complex_imagin;

            //取得乘法運(yùn)算后的虛部
            double complex_imagin = this.complex_real * c.complex_imagin + this.complex_imagin * c.complex_real;

            //返回一個(gè)復(fù)數(shù)類(lèi)
            return new complex(complex_real, complex_imagin);
        }

        //除法運(yùn)算結(jié)果 (a+bi)/(c+di)=(a+bi)(c-di)/(c+di)(c-di)
        public complex complex_divide(complex c)
        {
            //取得(c+di)(c-di)的值
            double d = c.complex_real * c.complex_real + c.complex_imagin * c.complex_imagin;

            //取得除法運(yùn)算后的實(shí)部
            double complex_real = (this.complex_real * c.complex_real + this.complex_imagin * c.complex_imagin) / d;

            //取得除法運(yùn)算后的虛部
            double complex_imagin = (this.complex_real * (-c.complex_imagin) + this.complex_imagin * c.complex_real) / d;

            //返回一個(gè)復(fù)數(shù)類(lèi)
            return new complex(complex_real, complex_imagin);
        }
    }


運(yùn)行結(jié)果:

復(fù)制代碼 代碼如下:
加法運(yùn)算結(jié)果:3+3i  
減法運(yùn)算結(jié)果:-1+-1i  
乘法運(yùn)算結(jié)果:0+4i  
除法運(yùn)算結(jié)果:0.5+0i 

AspNet技術(shù)asp.net(c#)復(fù)數(shù)類(lèi)(復(fù)數(shù)加減乘除四則運(yùn)算),轉(zhuǎn)載需保留來(lái)源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 在线观看色网 | 91免费播放 | 天天综合五月天 | 微拍秒拍福利一区二区 | 中日韩一线二线 | 91免费精品国偷自产在线在线 | 精品视频国产 | 99草精品视频 | 美女视频很黄很a免费国产 美女视频黄.免费网址 | 日韩一区二区三区视频在线观看 | 深爱婷婷网 | 黄色激情视频网址 | 91免费观看视频 | 国产区更新| 综合伊人久久在一二三区 | 91久久精品一区二区 | 中文字幕一区视频一线 | 色婷婷中文字幕 | 色天天干 | 精品国产午夜久久久久九九 | 小说区图片区综合久久88 | 在线观看国产小视频 | 亚洲综合激情视频 | 亚洲午夜大片 | 国产成人盗拍精品免费视频 | 成人青草亚洲国产 | 深夜免费小视频 | 一区二区免费视频 | 99久久综合狠狠综合久久 | 日韩精品中文字幕一区三区 | 一区 在线播放 | 精品精品国产自在久久高清 | 国产精品区一区二区免费 | 久久道| 日本高清午夜色wwwσ | 九色91精品国产网站 | 日本精品一区二区在线播放 | 久久99精品久久久久久秒播 | 最新国产在线视频 | 色哟哟免费在线观看 | 国产吧在线视频 |