2017-04-15 89 views
-4
#include <iostream> 
using namespace std; 

int main(){ 

int integer=400; 
int count=1; 

while (count == integer){ 
cout<< count<<endl; 

count = count + 1; 
} 

} 

這基本上是我用我的項目。似乎沒有輸出。幫幫我?雖然循環與整數不起作用

+0

你有沒有試過[橡皮鴨調試(維基百科)](https://en.wikipedia.org/wiki/Rubber_duck_debugging)?你應該試試! –

+0

while循環計算'count'變量的條件值爲'1','integer'變量的條件值爲'400'。 「count == integer」語句的計算結果爲false –

+1

此外,如果您有「int main」 – abeyaz

回答

2

count == integer正在評估爲false。我想你的意思是while (count < integer)

+0

,則應從函數中返回一個整數謝謝您的快速回復!它幫助了很多。 –

+0

如果使用==正在評估false並且不能使用<用於布爾格式?如何爲布爾格式變量做循環?我只是對C++ –

+0

這麼新而已,對於布爾格式使用'=='或'!=' –

0

你問程序用假的條件運行while循環,即您比較countinteger,其中前者的價值1,而後者被設置爲400(count == integer)將返回false,並且循環將簡單地跳過。

我認爲你正在試圖做的是 while (count < integer) 其中環將與count組開始爲1,增量爲1增加至400(根據count = count + 1;)。