你能修复这个程序吗?它不会计算 z。
int main()
{
using namespace std;
int x, y, z, a;
cout << "Please enter a number" << endl;
cin >> x;
cout << "Please enter another number" << endl;
cin >> y;
cout << "What do you want to do with these numbers?" << endl;
cout << "1 = +" << endl;
cout << "2 = -" << endl;
cout << "3 = *" << endl;
cout << "4 = /" << endl;
cin >> a;
do {
z = add(x, y);
} while (a == 1);
do {
z = sub(x, y);
} while (a == 2);
do {
z = mul(x, y);
} while (a == 3);
do {
z = dis(x, y);
} while (a == 4);
cout << z;
return 0;
}
我尝试使用 do while 语句,但我无法让它工作。---编辑---添加了适当的缩进,为什么它不能自动这样做?