主题:关于递归计数~~~
#include<stdio.h>
#include<stdlib.h>
void count(int);
int i=0;
int b;
int main(int argc,char* argv[])
{
sscanf(argv[1],"%d",&b);
count(i);
printf("%d\n",b);
return EXIT_SUCCESS;
}
void count(int i)
{
if(b>0)
{
if(i<b)
printf("%d,",i);
i++;
count(i)
}else{
if(i>b)
printf("%d,",i);
i--;
count(i);
}
}
[size=2]我输入5,输出0,1,2,3,4,5是对的
应该输入-5,输出为0,-1,-2,-3,-4,-5 可只输出了-5 ?????[/size]
#include<stdlib.h>
void count(int);
int i=0;
int b;
int main(int argc,char* argv[])
{
sscanf(argv[1],"%d",&b);
count(i);
printf("%d\n",b);
return EXIT_SUCCESS;
}
void count(int i)
{
if(b>0)
{
if(i<b)
printf("%d,",i);
i++;
count(i)
}else{
if(i>b)
printf("%d,",i);
i--;
count(i);
}
}
[size=2]我输入5,输出0,1,2,3,4,5是对的
应该输入-5,输出为0,-1,-2,-3,-4,-5 可只输出了-5 ?????[/size]