复数计算

  1. //  
  2. // Copyright (c) 2014软件技术1班  
  3. // All rights reserved.   
  4. // 作    者:A30  黄勇华  
  5. // 完成日期:2014年 12 月 13 日   
  6. // 版 本 号:v1.0   
  7. //   
  8. // 问题描述:编写复数计算器
  9. // 输入描述: 输入复数实部和虚部
  10. // 程序输出:输出计算结果
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Linq;
  14. using System.Text;
  15. namespace mine
  16. {
  17.     class Program
  18.     {
  19.         static void Main(string[] args)
  20.         {
  21.             Complex r1 = new Complex ();
  22.             Console.WriteLine("请输入第一个复数的实部");
  23.             r1.a = int.Parse(Console.ReadLine());
  24.             Console.WriteLine("请输入第一个复数的虚部");
  25.             r1.c = int.Parse(Console.ReadLine());
  26.             Console.WriteLine("请输入第二个复数的实部");
  27.             r1.b = int.Parse(Console.ReadLine());
  28.             Console.WriteLine("请输入第二个复数的虚部");
  29.             r1.d = int.Parse(Console.ReadLine());

  30.            Console.WriteLine("复数相加结果");
  31.             Console.WriteLine(r1.one()+"+"+r1.three()+"i");
  32.             Console.WriteLine("复数减法");
  33.             Console.WriteLine(r1.two() + "+" + r1.four() + "i");
  34.             Console.Read()
  35.         }
  1.         class Complex
  2.         {
  3.             public int a;
  4.             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;


                }






            }
            
        }


    }
  5. 输出:



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值