这道题怎么做?
如图 本帖最后由 jhq999 于 2022-5-10 12:04 编辑void qusu(int (*num),int *box,int n,int m,int *count)
{
int i;
if(0==m)
{
for (i = 0; box; i++);
for (i = i - 1; i >= 0 ; i--)
{
printf("%d",box);
}
(*count)++;
printf("\n");
return;
}
for (i = 0; i < n; i++)
{
if (0==num)
{
box=num;
num=1;
qusu(num,box,n,m-1,count);
num=0;
}
}
}
int main()
{
int n,m,count=0;
scanf("%d%d",&n,&m);
int (*num)=new int;
int *box=new int;
for (int i = 0; i < n; i++)
{
num=0;
num=i+1;
}
box=0;
qusu(num,box,n,m,&count);
printf("\n%d",count);
delete[] num;
delete[] box;
return 0;
}
void qusu(int (*num),int *box,int m,int *count)
{
int i;
if(0==m)
{
for (i = 0; box; i++);
for (i = i - 1; i >= 0 ; i--)
{
printf("%d",box);
}
(*count)++;
printf("\n");
return;
}
for (i = 0; num; i++)
{
if (0==num)
{
box=num;
num=1;
qusu(num,box,m-1,count);
num=0;
}
}
}
int main()
{
int n,m,count=0;
scanf("%d%d",&n,&m);
int (*num)=new int;
int *box=new int;
for (int i = 0; i < n; i++)
{
num=0;
num=i+1;
}
num=num=0;
box=0;
qusu(num,box,m,&count);
printf("\n%d",count);
delete[] num;
delete[] box;
return 0;
}
页:
[1]