struct node { int d; struct node *n; }*h,*p; int N,f;void fun(int,int); void push(int); void pop(); void prf(); void main() { h=(struct node *)malloc(sizeof(struct node)); h->n=NULL; h->d=-1; p=h; printf(\"请输入一个1-10的数:\"); scanf(\"%d\ fun(N,N); }
void fun(int n,int sum) { int i; for(i=n;i>0;i--) { if(sum==N) f=0; if((sum-i)>0) { push(i); fun(i,sum-i);
pop(); } if((sum-i)==0) { push(i); if(f!=0) printf(\ prf(); f++; pop(); } if(sum==N) printf(\"\\n\"); } }
void push(int x) { struct node *q; q=(struct node *)malloc(sizeof(struct node)); q->n=NULL; q->d=x; p->n=q; p=q; }
void pop() { struct node *q; q=h; while(q->n!=p) { q=q->n; } p=q; q=p->n; p->n=NULL; free(q); }
void prf() { struct node *q; q=h->n; while(q!=NULL) { printf(\"%d\
}
}
q=q->n;
if(q!=NULL) printf(\"+\");