#include < stdio.h > #include < malloc.h > typedef struct node ... { int data; struct node *next;} list, * Node;Node copy(Node t);Node reverse(Node head); void output(Node head);Node jieCheng( int n) ... { int i; int j; int sum; int r;//余数 int p=0;//进位 Node temNode=NULL; Node p1; Node p2; Node result=NULL; Node tem=NULL; if(n>=1) ...{ tem=(Node)malloc(sizeof(list)); tem->data=1; tem->next=NULL; result=(Node)malloc(sizeof(list)); result->data=1; result->next=NULL; } for(i=2;i<=n;i++) ...{ for(j=1;j<i;j++) ...{ p1=result; p2=tem; p=0; while(p1!=NULL&&p2!=NULL) ...{ sum=p1->data+p2->data+p; r=sum%10; p=sum/10; p1->data=r; p1=p1->next; p2=p2->next; } while(p1!=NULL) ...{ sum=p1->data+p; r=sum%10; p=sum/10; p1->data=r; p1=p1->next; } if(p!=0) ...{ p1=result; while(p1->next!=NULL) ...{ p1=p1->next; } temNode=(Node)malloc(sizeof(list)); temNode->data=p; temNode->next=NULL; p1->next=temNode; } } tem=copy(result); } return result;} Node copy(Node t) ... { Node tt=t; Node head=NULL; Node tem=NULL; Node rear=NULL; //int a[]={1,2,3,4,5,6}; while(tt!=NULL) ...{ tem=(Node)malloc(sizeof(list)); tem->data=tt->data; tem->next=NULL; if(head==NULL) ...{ head=tem; rear=tem; } else ...{ rear->next=tem; rear=rear->next; } tt=tt->next; } return head;} Node reverse(Node head) ... { Node p=NULL; Node q=head; Node r=q->next; while(r!=NULL) ...{ q->next=p; p=q; q=r; r=r->next; } q->next=p; return q;} void output(Node head) ... { Node tem=head; while(tem!=NULL) ...{ printf("%d",tem->data); tem=tem->next; }} void main() ... { //printf("dsfsdfsdf"); Node result; result=jieCheng(100); result=reverse(result); output(result); printf(" "); //head=reverse(head); //output(head);}