当前位置:编程学习 > C#/ASP.NET >>

C#.Net写的Juliet集程序

选了一门物理学的课,老师留的作业,试着用C#写了下。分享下程序代码和大家交流一下。

\

\

代码:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

 

namespace WindowsFormsApplication2

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

        // 复数类

        public class Complex

        {

            //默认构造函数

 

            public Complex()

                : this(0, 0)

            {

            }

 

            // 只有实部的构造函数

 

            public Complex(double real)

                : this(real, 0)

            {

            }

 

            // 由实部和虚部构造

 

            public Complex(double real, double image)

            {

                this.real = real;

                this.image = image;

            }

 

            private double real;

 

            public double Real

            {

                get { return real; }

                set { real = value; }

            }

 

            private double image;

 

            // 复数的虚部

 

            public double Image

            {

                get { return image; }

                set { image = value; }

            }

 

            //重载加法

 

            public static Complex operator +(Complex c1, Complex c2)

            {

                return new Complex(c1.real + c2.real, c1.image + c2.image);

            }

 

            //重载减法

 

            public static Complex operator -(Complex c1, Complex c2)

            {

                return new Complex(c1.real - c2.real, c1.image - c2.image);

            }

 

            //重载乘法

 

            public static Complex operator *(Complex c1, Complex c2)

            {

                return new Complex(c1.real * c2.real - c1.image * c2.image, c1.image * c2.real + c1.real * c2.image);

            }

 

        }

       

        private void button1_Click(object sender, EventArgs e)

        {

           

            int nColor;

            int nRed;

            int nGreen;

            int nBlue;

            double cx;

            double cy;

           

 &nbs

补充:软件开发 , C# ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,