- //
- // Copyright (c) 2014软件技术1班
- // All rights reserved.
- // 作 者:A09
- // 完成日期:2014年 12 月 13 日
- // 版 本 号:v1.0
- //
- // 问题描述:创建一个程序来计算复数的加减
- // 输入描述:两个复数
- // 程序输出:一个复数
- //
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication198
{
class Program
{
static void Main(string[] args)
{
Complex x = new Complex();
NewMethod(x);
x.Add();
Console.WriteLine("两个复数相加为{0}+{1}i", x.a, x.b);
x.Reduction();
Console.WriteLine("两个复数相减为{0}{1}{2}i", x.a, x.symbol, x.b);
Console.Read();
}
private static void NewMethod(Complex x)
{
Console.WriteLine("请输入第一个复数的a");
x.a1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请输入第一个复数的b");
x.b1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请输入第二个复数的a");
x.a2 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请输入第二个复数的b");
x.b2 = Convert.ToInt32(Console.ReadLine());
}
class Complex
{
public int a1, b1, a2, b2, a, b;
public string symbol;
public void Add()
{
a = a1 + a2;
b = b1 + b2;
}
public void Reduction()
{
a = a1 - a2;
b = b1 - b2;
if (b < 0) symbol = "";
else symbol = "+";
}
}
}
}
总结:
1.通过本作业我学会了复数计算知识
2.解决了复数计算的问题,增长了经验,收获了自信
3.我还需更加努力