复数的计算

  1. //  
  2. // Copyright (c) 2014软件技术1班  
  3. // All rights reserved.   
  4. // 作    者:A09    
  5. // 完成日期:2014年 12 月 13 日   
  6. // 版 本 号:v1.0   
  7. //   
  8. // 问题描述:创建一个程序来计算复数的加减 
  9. // 输入描述:两个复数 
  10. // 程序输出:一个复数
  11. // 
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.我还需更加努力


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值