Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/130.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 带整数的While循环不起作用 #包括 使用名称空间std; int main(){ 整数=400; 整数计数=1; while(count==整数){ cout_C++_While Loop_Integer - Fatal编程技术网

C++ 带整数的While循环不起作用 #包括 使用名称空间std; int main(){ 整数=400; 整数计数=1; while(count==整数){ cout

C++ 带整数的While循环不起作用 #包括 使用名称空间std; int main(){ 整数=400; 整数计数=1; while(count==整数){ cout,c++,while-loop,integer,C++,While Loop,Integer,count==integer的计算结果为false。我想你的意思是while(count

count==integer
的计算结果为false。我想你的意思是
while(count
你要求程序运行一个带有false条件的while循环,也就是说,你正在比较
count
integer
,前者的值为
1
,后者设置为
400
(count==integer)
将返回false,循环将被跳过

我想你想做的是
while(count

其中循环将以
count
设置为1开始,并以1为增量增加到400(根据
count=count+1;
).

您试过吗?您应该试一下!当while循环计算
count
变量的条件值为
1
时,
integer
变量的条件值为
400
。语句
count==integer
也计算为false时,如果您有“int main”,则应从函数返回一个整数感谢您的快速回复!它帮助了很多。如果使用==计算为false,并且不能使用<作为布尔格式,我将如何为布尔格式变量执行循环?我只是对c++使用
==
!=
作为布尔格式非常陌生
#include <iostream>
using namespace std;

int main(){

int integer=400;
int count=1;

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

count = count + 1;
}

}