I chose a physics course, and the assignment left by the teacher tried to write it in C. Share the program code and share it with you.
Code:
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 ();
}
// Plural
Public class Complex
{
// Default constructor
Public Complex ()
: This (0, 0)
{
}
// Only real-part Constructors
Public Complex (double real)
: This (real, 0)
{
}
// Constructed from the real and virtual parts
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;
// The imaginary part of the plural number
Public double Image
{
Get {return image ;}
Set {image = value ;}
}
// Overload Addition
Public static Complex operator + (Complex c1, Complex c2)
{
Return new Complex (c1.real + c2.real, c1.image + c2.image );
}
// Overload Subtraction
Public static Complex operator-(Complex c1, Complex c2)
{
Return new Complex (c1.real-c2.real, c1.image-c2.image );
}
// Overload Multiplication
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 button#click (object sender, EventArgs e)
{
Int nColor;
Int nRed;
Int nGreen;
Int nBlue;
Double cx;
Double cy;
& Nbs