⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 12i.cpp

📁 C/C++程序设计导论(第二版)》程序源文件
💻 CPP
字号:
// cmath.cpp  A program to do complex math.
#include <iostream.h>
#include "complex.h"
void main ()
{	char choice;
	Complex a, b, c;					// three Complex variables
	cout << "enter a complex number pair such as (5.1,2.3i): ";
	a.InputC(cin);					// input cmplx into `a'
	cout << "enter a complex number pair such as (5.1,2.3i): ";
	b.InputC(cin);					// input cmplx into `b'
	cout << "enter choice: (a)dd, (s)ub, (m)ult: ";
	cin >> choice;					// get user's choice
	switch (choice)
	{	case 'a' :			c = a.AddC (b);	// add `b' to `a', assign to `c'
					break;
		case 's' :			c = a.SubC (b);		// sub `b' from `a'
					break;
		case 'm' :			c = a.MultC (b);		// mult `b' to `a'
					break;
		default : 			cout << "entry error";
	}
	c.OutputC(cout);					// display results.
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -