有什么帮助吗?当我输入这两个数字时,它说答案没有被初始化......?
#include <iostream>
using namespace std;
int main()
{
int num;
int num2;
int working;
int answer;
int uChoice;
int work( int one, int two, int todo );
cout << "Welcome to my Basic Mini-Calculator!" << endl;
do
{
cout << endl << "What do you want to do?" << endl;
cout << "1) Add" << endl;
cout << "2) Subtract" << endl;
cout << "3) Multiply" << endl;
cout << "4) Divide" << endl;
cout << endl << "Waiting for input... (enter a number): ";
cin >> uChoice;
cout << endl;
} while( uChoice != 1 && uChoice != 2 && uChoice != 3 && uChoice != 4 );
switch ( uChoice )
{
case 1:
cout << endl << "You chose addition." << endl;
cout << "Enter a number: ";
cin >> num;
cout << "Enter another number: ";
cin >> num2;
working = num + num2;
cout << "Your answer is: " << answer;
break;
case 2:
cout << endl << "You chose subtraction." << endl;
cout << "Enter a number: ";
cin >> num;
cout << "Enter another number: ";
cin >> num2;
working = num - num2;
cout << "Your answer is: " << answer;
break;
case 3:
cout << endl << "You chose multiplication." << endl;
cout << "Enter a number: ";
cin >> num;
cout << "Enter another number: ";
cin >> num2;
working = num * num2;
cout << "Your answer is: " << answer;
break;
case 4:
cout << endl << "You chose division." << endl;
cout << "Enter a number: ";
cin >> num;
cout << "Enter another number: ";
cin >> num2;
working = num / num2;
cout << "Your answer is: " << answer;
break;
return 0;
}
}