用Gauss-Seidel迭代法解线性方程组的C语言源代码:
#include
#include
#include
struct Line{
};
struct Row{
int R; float x; int L; struct Row *head; struct Line *next;
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(i<=Line){
while(j<=Row+1){
scanf("%f",&X); if(X!=0||j==Row+1){ ptr1=(struct Row*)malloc(sizeof(Row)); if(ptr1==NULL){ printf("内存分配错误!\n"); } ptr1->x=X; ptr1->R=j; if(ptr2==NULL){ ptr2=ptr1; Rhead=ptr1; } else{ exit(1);