下面的代码应该询问用户他的体重,如果用户输入> 15,它应该执行一个while循环将其增加到50代码编译成功,但无论你输入> 15它都不会执行while循环.
#include <iostream>
using namespace std;
int main()
{
int weight;
cout << "Current weight?" << endl;
cin >> weight;
cout << "Your weight:" << weight << endl;
if (weight > 15) {
while (weight == 50) {
weight = weight + 1;
cout << "Weight:" << weight << endl;
}
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)