- //
- // Copyright (c) 2014软件技术1班
- // All rights reserved.
- // 作 者:A30 黄勇华
- // 完成日期:2014年 12 月 13 日
- // 版 本 号:v1.0
- //
- // 问题描述:编写复数计算器
- // 输入描述: 输入复数实部和虚部
- // 程序输出:输出计算结果
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace mine
- {
- class Program
- {
- static void Main(string[] args)
- {
- Complex r1 = new Complex ();
- Console.WriteLine("请输入第一个复数的实部");
- r1.a = int.Parse(Console.ReadLine());
- Console.WriteLine("请输入第一个复数的虚部");
- r1.c = int.Parse(Console.ReadLine());
- Console.WriteLine("请输入第二个复数的实部");
- r1.b = int.Parse(Console.ReadLine());
- Console.WriteLine("请输入第二个复数的虚部");
- r1.d = int.Parse(Console.ReadLine());
-
- Console.WriteLine("复数相加结果");
- Console.WriteLine(r1.one()+"+"+r1.three()+"i");
- Console.WriteLine("复数减法");
- Console.WriteLine(r1.two() + "+" + r1.four() + "i");
- Console.Read()
- }
- class Complex
- {
- public int a;
- public int b;
public int c;
public int d;
public int one()
{
return a + b;
}
public int two()
{
return a - b;
}
public int three()
{
return c + d;
}
public int four()
{
return c - d;
}
}
}
}
- 输出:
-