12i.cpp
来自「《C/C++程序设计导论(第二版)》一书的程序源文件」· C++ 代码 · 共 24 行
CPP
24 行
// 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 + =
减小字号Ctrl + -
显示快捷键?