小编Sco*_*Kim的帖子

而循环和cin

下面的代码应该询问用户他的体重,如果用户输入> 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)

c++ while-loop

0
推荐指数
1
解决办法
97
查看次数

标签 统计

c++ ×1

while-loop ×1