程序设计:两个复数和差计算
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.有利于后面程序问题的解决,增强了我对程序设计的兴趣
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.有利于后面程序问题的解决,增强了我对程序设计的兴趣
相关文章推荐
- PAT程序设计考题——甲级1009(计算两个多项式相乘的积)
- 作业五-设计一个程序计算输入的两个数的和与差,要求自定义一个函数 sum_diff(float op1, float op2, float *psum, float *pdiff),其中 op1 和 op2 是输入的两个数,*psum 和*pdiff 是计算得出的和与差.
- 设计一个程序输入两个日期计算相隔多少天,或计算一个日期加上间隔后的日期。
- 123、设计4个线程,其中两个线程每次对j增加1,另外两个线程对j每次减少1。写出程序。
- 行列式计算程序设计
- 用抽象类设计计算二维平面图形面积的程序
- 编写两个Shell程序kk及aa,在kk中输入两个数,调用aa计算计算这两个数之间奇数的和。
- 使用c语言编写程序,从键盘上任意输入两个数字,并计算出两个数的最小公倍数
- 设计一个个人纳税计算程序
- 设计一个个人纳税计算程序
- 设计vb程序计算税率
- 从《全球排名第一SETI@Home贡献者被学校开除》引发的网格计算程序的机制设计考虑
- 根据指定两个日期计算出这些时间内有多少天是周末 php程序函数代码
- 根据指定两个日期计算出这些时间内有多少天是周末 php程序函数代码
- python构架的科学计算程序设计(转载)
- 帮同学写的题:设计一个程序完成下面的计算:k!/(m!+n!)
- 编写一个程序来计算这两个序列不断变化的总和,直到达到某个次数。让用户交互地输入这个次数。
- 从'计算两个日期天数之差'程序介绍RPG语言
- 设计4个线程,其中两个线程每次对j增加1,另外两个线程对j每次减少1。写出程序。
- C语言编写的计算两个日期之间天数的程序