您的位置:首页 > 其它

程序设计:两个复数和差计算

2014-12-08 14:30 351 查看
01.//  

02.// Copyright (c) 2014软件技术2班  

03.// All rights reserved.   

04.// 作    者:B05 李刘杰

05.// 完成日期:2014年 12月 8日   

06.// 版 本 号:v1.0   

07.//   

08.// 问题描述:创建一个程序来,该程序初始化两个复数,然后两个复数的和与差,输出。  

09.// 输入描述:两个复数

10.// 程序输出:两个复数的和与差
11//.
using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace ConsoleApplication115

{

    class Program

    {

        static void Main(string[] args)

        {

            Console.Title ="复数计算";

            Complex P1 = new Complex();

            P1.a=1;

            P1.b=2;

            P1.c=3;

            P1.d=4;

            Console.WriteLine("初始化两个复数:{0}+{1}i、{2}+{3}i", P1.a, P1.b, P1.c, P1.d);

            Console .WriteLine("两个复数之和:"+"{0}" + "+{1}" ,P1.realpart1(), P1.imaginarypart1());

            Console.WriteLine("两个复数之差:"+ "{0}" + "{1}" , P1.realpart2(), P1.imaginarypart2());

             Console .ReadKey();

        }

    }

    class Complex

    {

        public int a;

        public int b;

        public int c;

        public int d;

        public int  realpart1()

        {

            return       a + c;

        

        

        }

        public string imaginarypart1()

        {

           

             

          return    (b+d)+"i";

         

        }

        public int realpart2()

        {

            return       a - c;

        

        

        

        }

        public string imaginarypart2()

     {

        return    (b-d)+"i";

        

       }

        }

       

   

    

    }

  

12.//效果图:


  

总结:1.通过本作业我学会了设计有关用类来编写程序等知识

2.解决了相关程序计算的问题,增长了经验,收获了自信

3.有利于后面程序问题的解决,增强了我对程序设计的兴趣
              
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐