用Gauss-Seidel 迭代法解线性方程组的 C 语言源代码: #include #include #include struct Line{ int L; struct Row *head; struct Line *next; } ; struct Row{ int R; float x; struct Row *link; } ; //建立每次迭代结果的数据存储单元 struct Term{ float x; float m; } ; struct Line *Create(int Line,int Row){ struct Line *Lhead=NULL,*p1=NULL,*p2=NULL; struct Row*Rhead=NULL,*ptr1,*ptr2=NULL; int i=1,j=1; float X; while(iR=j; if(ptr2==NULL){ ptr2=ptr1; Rhead=ptr1; } else{ ptr2->link=ptr1; ptr2=ptr1; } } j++; } if(ptr2
=NULL){ ptr2->link=NULL; ptr2=NULL; } if(Rhead
=NULL){ p1=(struct Line*)malloc(sizeof(Line)); if(p1==NULL){ printf("内存分配错误
\n"); exit(1); } p1->L=i; p1->head=Rhead; if(p2==NULL){ Lhead=p1; p2=p1; } else{ p2->next=p1; p2=p1; } } i++; Rhead=NULL; j=1; } if(p2
=NULL) p2->next=NULL; return Lhead; } struct Line *Change(struct Li