| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1372 人关注过本帖
标题:[原创]Gauss消元法求解线性方程组c源程序
只看楼主 加入收藏
zhangzujin
Rank: 1
等 级:新手上路
帖 子:276
专家分:0
注 册:2005-5-9
收藏
 问题点数:0 回复次数:1 
[原创]Gauss消元法求解线性方程组c源程序

看了Gauss消元法,自己作了个c程序,大家有兴趣,运行看看。 #include<stdio.h> #include<math.h> #include<conio.h> #define N 100 #define epsilon 1e-6 float a[N][N+1],s=0;

void main( ) { int i,j,n,k,l; clrscr( ); printf("It is strongly recommended that you read this before you run the programming:\n"); printf("1.This is Gauss method to solve linear equations.\n"); printf("2.Please review the principles of Gauss method.\n"); printf("3.Be careful,don't just depend on computers,you have mind!\n"); printf("4.Probably there are some defects in this programme.\n"); printf(" If any,please send messages to the creator.\n"); printf("5.Copyright 2005-5-12 Zhang Zujin\n"); printf(" QQ:283421560 E-mail:zhangzujin360732@163.com\n"); printf("\n"); printf("Input fangzhen jieshu:"); scanf("%d",&n); printf("Input Extended Matrix:\n"); for(i=0;i<n;i++) for(j=0;j<n+1;j++) scanf("%f",&a[i][j]); for(k=0;k<n-1;k++) { if(abs(a[k][k])<epsilon) { printf("Error,Gauss can't be durable,break at %d!\n",k+1); return; } else { for(i=k+1;i<n;i++) { a[i][k]=a[i][k]/a[k][k]; for(j=k+1;j<n+1;j++) a[i][j]=a[i][j]-a[i][k]*a[k][j]; } printf("\n*******The Final Equations*******\n"); for(k=0;k<n;k++) { for(j=0;j<k;j++) printf(" 0.00"); for(j=k;j<n+1;j++) printf("%8.2f",a[k][j]); printf("\n"); } } } if(abs(a[n-1][n-1])<epsilon) { printf("Error,Divid cann't be executed,break at %d!\n",n); return; } else { a[n-1][n]=a[n-1][n]/a[n-1][n-1]; for(k=n-2;k>=0;k--) { s=0; for(j=k+1;j<n;j++) s+=a[k][j]*a[j][n]; a[k][n]=(a[k][n]-s)/a[k][k]; } } printf("\n******* The Roots *******\n"); for(k=0;k<n;k++) printf(" x[%d]=%.2f\n",k+1,a[k][n]); getch( ); }

搜索更多相关主题的帖子: Gauss 线性方程 求解 
2005-05-14 11:17
tary
Rank: 1
等 级:新手上路
帖 子:780
专家分:0
注 册:2004-10-5
收藏
得分:0 
GUESS消元法,这是啥法啊??  程序没用心去看... 所以.........

┌→¨ ≮我可以学会对你很冷落≯¨←┐ │  <却学不╓══╦══╖会将爱> │ │¨←┐ ╭╩╮哭‖哭╭╩╮ ┌→¨│ └──┘收 ╲╱ ◇‖◇ ╲╱回└──┘
2005-05-14 15:36
快速回复:[原创]Gauss消元法求解线性方程组c源程序
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011146 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved