以下来自啊哈算法这本书,用于输出数字全排列,发现注释掉的return属于多余。这是怎么回事啊???
#include
int a[10],book[10],n;
void dfs(int step)
{
int i,j;
if (step == n+1)
{
for ( i = 1; i<=n; i++ )
printf("%d",a[i]);
//return;
}
for (i = 1; i<=n; i++)
{
if (book[i]==0)
{
a[step]=i;
book[i]=1;
dfs(step+1);
book[i]=0;
}
}
//return;
}
int main()
{
scanf("%d",&n);
dfs(1);
getchar();
getchar();
return 0;
}