怎么会这样子??

来源:百度知道 编辑:UC知道 时间:2024/06/14 17:02:17
#include <iostream>
using namespace std;
int main()
{
for(int i=0;i<4;i++){
for(int h=0;h<5;h++){
if(h=1)

cout<<'*'<<'\t';
}cout<<'\n';
}
} 运行结果出现了满屏幕的*,而当if(h=5)或者5以上的值的时候又会出现
*
*
*
*
这是为什么啊,很让我困惑!!!!!!
我知道在c++中=是赋侄==是等于
但是请高手详细解释,为什么会出现现了满屏幕的*,

正确的程序应该这样:
#include <iostream>
using namespace std;
int main()
{
for(int i=0;i<4;i++){
for(int h=0;h<5;h++){
if(h==1) /*你用了=号,应该是==,因为它是用来判断是否等于1的*/

cout<<'*'<<'\t';
}cout<<'\n';
}
system("pause"); /*让程序结果显示在屏幕上*/
}

是不是标点符号错了。。。。。。。。。。。