回复 2楼 自学的数学
万分感谢。 #include <stdio.h>
#include <stdlib.h>
typedef struct node
{
int *data;
int front;
int real;
int k;
}queue;
void create(queue *s,int n,int m)
{
int sum,i;
s->data=(int *)malloc(n*sizeof(int));
s->k=n;
s->front=0;
s->real=s->front;
for(i=0;i<n-1;i++)
s->data[s->real++]=0;
s->data[s->real]=1;
while(1)
{
s->real++;
if((s->real)%s->k==s->front)
s->real=s->front;
sum=0;
for(i=0;i<n;i++)
sum+=s->data[i];
if(sum>m)
break;
else
s->data[s->real]=sum;
}
for(i=0;i<n;i++)
{
if((s->real)%s->k==s->front)
s->real=s->front;
printf("%d ",s->data[s->real++]);
}
}
int main()
{
queue *s;
int n,m;
s=(queue *)malloc(sizeof(queue));
scanf("%d %d",&m,&n);
create(s,n,m);
return 0;
}这是我同学写的,可以看看。