[c++]代码库
#include <iostream.h>
int main() {
double displayed_value;
double new_entry;
char command_character;
displayed_value = 0.0;
cout << "计算器演示程序" << endl
<< "----" << endl;
cout << "在'>' 提示后输入一个命令字符"
<< endl;
cout << "Value : " << displayed_value << endl;
cout << "command>";
cin >> command_character;
while (command_character != 'Q') {
switch(command_character) {
case 'C':
displayed_value = 0.0;
break;
case '+':
cout << "number>";
cin >> new_entry;
displayed_value += new_entry;
break;
case '-':
cout << "number>";
cin >> new_entry;
displayed_value -= new_entry;
break;
case '*':
cout << "number>";
cin >> new_entry;
displayed_value *= new_entry;
break;
case '/':
cout << "number>";
cin >> new_entry;
displayed_value /= new_entry;
break;
default:
cout << "不可理解的输入!";
cin.ignore(100, '\n');
} //End of switch
cout << "Value : " << displayed_value << endl;
cout << "command>";
cin >> command_character;
} //End of while
return 0;
}
初级程序员
by: 我的程序员之路 发表于:2013-05-23 23:17:19 顶(0) | 踩(1) 回复
还以为是GUI版本的,很久没看C++了
回复评论