注册 登录
编程论坛 C++教室

请不各位指教

deng0981 发布于 2011-11-08 23:32, 514 次点击
#include<iostream>
using namespace std;
void print(int w)
{ int i;
  if( w ) //怎么理解
    { print( w-1 );
      for( i=1; i<=w; i++ )
cout << w << "  ";
      cout << endl;
     }
}
void main()
{  print( 5 );
}
现有一递归函数。想请教,通常if 是用于判断。if括号里,只有一个变量,是怎么理解
2 回复
#2
非死亡!2011-11-09 18:45
当w!=0时执行
在判断中 所有非0的数 表达式都是真 即是1
if(3) 是真
if(0)是假
if(5+9)是真
#3
deng09812011-11-09 21:39
回复 2楼 非死亡!
明白。谢了
1