一区二区久久-一区二区三区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)系我們修改或刪除,多謝。

主站蜘蛛池模板: yiren22亚洲综合高清一区 | 精品视频99| 国产一区二区三区久久 | 国产自在线观看 | 国产精品久久久久久福利69堂 | 狠狠干婷婷 | 一级做性色a爰片久久毛片免费 | 日韩综合nv一区二区在线观看 | 国产一级毛片午夜福 | 精品视频在线一区 | 亚洲精品小视频 | 二区国产| 亚洲欧美日韩精品香蕉 | 精品国产夜色在线 | 国产精品第六页 | 美女一级毛片毛片在线播放 | 成人自拍视频在线观看 | 不卡视频一区 | 国产91精品福利在线观看 | 91麻豆tv| 亚洲欧美日韩国产精品第不页 | 久久久最新精品 | 免费观看成人鲁鲁鲁鲁鲁视频 | 91成人影院未满十八勿入 | 成人特黄午夜性a一级毛片 成人婷婷 | 四虎影视成人永久在线观看 | 亚洲一区二区三区四区在线观看 | 精品日韩二区三区精品视频 | 色多多在线免费观看 | 一本中文字幕一区 | 好吊妞在线观看 | 成人亚洲网站 | 美女国产在线观看免费观看 | 亚洲丝袜中文字幕 | 精品自拍视频在线观看 | 在线播放一区二区精品产 | 中文字幕一级毛片视频 | 久久福利网 | 6080午夜乱理伦片 | 丰满美女毛片 | 精品伊人久久久香线蕉 |