#include <iostream.h>
void main()
{
float num1;
float num2;
char op;
float ans;
cout << "Please enter a number: " ;
cin >> num1;
cout << "please entet another nunber: " ;
cin >> num2;
cout << "press A to add the two numbers."
<< endl
<< "press S to subtract the two numbers."
<< endl
<< "press M to multiply the two numbers."
<< endl
<< "press D to divide the two numbers."
<< endl;
cin.ignore();
cin >> op;
if (op == 65)
{
ans = num1 + num2;
cout << "The answet is " << ans << endl;
}
if (op == 83)
{
ans = num1 - num2;
cout << "The answet is " << ans << endl;
}
if (op == 77)
{
ans = num1 * num2;
cout << "The answet is " << ans << endl;
}
if (op == 68)
{
ans = num1 / num2;
cout << "The answet is: " << ans << endl;
}
if (op != 65 && op !=83 && op != 77 && op != 68)
{
cout << "No valid operation was chosen!" << endl;
}
}
没有输出最后的结果!?
[此贴子已经被作者于2007-3-8 10:09:03编辑过]