电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

迭代法解线性方程组(C语言描述)VIP免费

迭代法解线性方程组(C语言描述)_第1页
1/6
迭代法解线性方程组(C语言描述)_第2页
2/6
迭代法解线性方程组(C语言描述)_第3页
3/6
用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(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"); exit(1); } ptr1->x=X; ptr1->R=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 Line*Lhead,int n){ struct Line*p1,*p2,*p3,*p; struct Row*ptr; int i=1,k,j; float max,t; if(Lhead==NULL){ printf("链表为空!\n"); exit(1); } p2=Lhead; while(i<=n){ max=0; k=0; t=0; ptr=p2->head; while(ptr!=NULL){ if(ptr->R!=n+1){ t+=fabs(ptr->x); if(maxx)){ max=fabs(ptr->x); k=ptr->R; } } ptr=ptr->link; } t=t-max; if(max<=t){ printf("系数矩阵A 不具有严格对角优势,该程序不能用 Gauss-Jacobi 迭代法解该方程组!\n"); return NULL; } if(p2->L==k) p2=p2->next; else if(p2->L>k){ printf("系数矩阵A 不具有严格对角优势,该程序不能用 Gauss-Jacobi 迭代法解该方程组!\n"); exit(0); } else{ p3=Lhead; while(p3->L!=k) p3=p3->next; ptr=p3->head; p3->head=p2->head; p2->head=ptr; } i++; } return Lhead; } void Deal(struct Line *Lhead,float e,int N,int n){ struct Term*ptr; struct Line*p1...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

迭代法解线性方程组(C语言描述)

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部