首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

关于循环条件 生手救助

2013-09-06 
关于循环条件新手救助。代码一#includestdio.hint main(void){int numint xhwhile (scanf (%d\n,&num

关于循环条件 新手救助。
  代码一  
 #include<stdio.h>
int main(void)
{
     int num;
     int xh; 
     
     while (scanf ("%d\n",&num),xh  == 0);
          {
                   printf(" yes , enter cycle!\n");
          }

     printf("no Cycle\n",num);
     return 0;
}



   运行结果
  我输入了   20
            14
 输出了
              yes , enter cycle!
              no Cycle
       

我 在循环条件那里将 xh  == 0。后来有改成了  xh = 0  都不行,
         不是 值为0 时 为假吗。
    按理说不应该 出现  yes ,enter cycle 啊。
         好像是语法哪里出了问题。   求解
[解决办法]


  while (scanf ("%d\n",&num),xh  == 0);
// 除掉分号吧! == 是判断, = 是赋值
  while (scanf ("%d\n",&num),xh  == 0)

热点排行