12v.cpp
来自「C/C++程序设计导论(第二版)》程序源文件」· C++ 代码 · 共 25 行
CPP
25 行
// cmath3.cpp A program to do complex math. Assumes
// Complex can be treated as any other simple numerical data type.
#include <iostream.h>
#include "complex3.h"
void main ()
{ char choice;
Complex a, b, c; // three Complex variables
cout << "enter a complex number pair: ";
cin >> a; // input cmplx into `a'
cout << "enter a complex number pair: ";
cin >> b; // 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 + b; // add `b' to `a', assign to `c'
break;
case 's' : c = a - b; // sub `b' from `a'
break;
case 'm' : c = a * b; // mult `b' to `a'
break;
default : cout << "entry error";
}
cout << c; // display results.
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?