gpt4 book ai didi

c++ - 为什么我的 do while 语句不起作用

转载 作者:行者123 更新时间:2023-11-28 07:44:19 26 4
gpt4 key购买 nike

<分区>

你能修复这个程序吗?它不会算出 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 语句,但我无法让它工作。 - -编辑 - -添加了适当的缩进,为什么它不会自动这样做?

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com