solve函数c语言_C语言解线性方程的四种方法

这是一个C语言程序,用于解决线性方程组,提供了高斯消元法、高斯-约当法、迭代法和克莱姆法则四种解法。程序可能存在浮点数处理问题,可能导致非零矩阵计算结果错误。用户可以输入方程组的系数和常数,选择解法进行计算。
摘要由CSDN通过智能技术生成

发了好几天编了个解线性方程组的小程序,可第一次实战就大败而归。经过半天的调试,仍找不出纠正的方法。因为并不是算法的问题,而是因为自己对编译器处理 浮点函数的方法不是很理解。明明D=0的方阵解出来不等于0了,跟踪调试发现,计算过程程序对数据进行了舍去处理,导致最终结果不对。不过如果没有浮点型 的话,这个程序应该算不错了 。

#include

#include

#include

#define NUM 100

void print(void)     /* 使用说明 */

{ clrscr();

printf("\n\n\n\n\n\t\t\t\t Introduction \n");

printf("\t*--------------------------------------------------------------*\n");

printf("\t*    This program was design for compute linear equations.       *\n");

printf("\t*    The way of use it is very simple.                           *\n");

printf("\t*    First : Input the number of the equation;(Input 0 to exit) *\n");

printf("\t*    Second: Input the coefficient of every eqution;             *\n");

printf("\t*    Third : Input the constant of every eqution;                *\n");

printf("\t*    Last : Chose the way you want use to solve the equtions; *\n");

printf("\t*    That's all, input any key to run it . . .                   *\n");

printf("\t*-------------------------By__TJX------------------------------*\n");

getch(); }

void chose(void)    /*选择计算方法*/

{ clrscr();

fflush(stdin);

printf("\n\n\n\n\n\t\t**********Introduction********** \n");

printf("\t\t* Chose the way,please.        * \n");

printf("\t\t* a : Gauss eliminant.         * \n");

printf("\t\t* b : Gauss_yd eliminant.      * \n");

printf("\t\t* c : Iterative way.           * \n");

printf("\t\t* d : Cramer way.              * \n");

printf("\t\t* e : exit.                    * \n");

printf("\t\t*************By__TJX************ \n");

printf("\t\tPlease choose number :\n");}

void input(double **a1,double b1[],int num)    /*数据输入*/

{ int i,j,t;

double *p;

char d

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值