我的目標這個程序是從用戶獲得輸入值「Y」,然後通過0乘以該數值,1,2,3,4,5,6,7 ,8,9,然後打印出10個結果。現在,當用戶輸入'y'的值時,程序只返回一個零列表。任何想法我做錯了什麼?While循環即遞增變量的點
#include <iostream>
using namespace std;
int main(){
int x;
int y;
int z;
x = 0;
z = x * y;
cout << "enter y" << endl;
cin >> y;
while (x < 10) {
cout << z << endl;
x = x + 1;
}
}
啓用更多編譯器警告並重新閱讀C++書籍的前幾章。 –
你甚至沒有改變變量'z'在循環。你還期望什麼? –