⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 8-6.cs

📁 java基础方面的一些实例代码
💻 CS
字号:
//程序8-6
using System;
public struct Complex 
{
	public int real;
	public int imaginary;
	public Complex(int real, int imaginary) 
	{	this.real = real;
		this.imaginary = imaginary;
	}
	public static Complex operator +(Complex c1, Complex c2) 
	{	return new Complex(c1.real + c2.real, c1.imaginary + c2.imaginary);
	}
	public static Complex operator - (Complex c1, Complex c2) 
	{	return new Complex(c1.real - c2.real, c1.imaginary - c2.imaginary);
	}
}
public class Test
{
	public static void Main() 
	{	Complex num1 = new Complex(1,2);
		Complex num2 = new Complex(3,4);
		Complex sum = num1 + num2;
		num2-=num1;
		Console.WriteLine("First complex number:  {0}+{1}i",num1.real,num1.imaginary);
		Console.WriteLine("Second complex number: {0}+{1}i",num2.real,num2.imaginary);
		Console.WriteLine("The sum of the two numbers: {0}+{1}i",sum.real,sum.imaginary);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -