下面的代碼應該詢問用戶他的體重,如果用戶將> 15,如果你把> 15,它不會做它應該做一個while循環將其提高到50 代碼編譯成功,但無論while循環。While循環和CIN
#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;
}
它做while循環..其唯一的打印在50 –