/**
* author:johnny zen
* date:2017-09-20 11:19
* function:Calculate Ternary system of equations
* notice:时间仓促,仅仅实现功能,方便使用,代码质量不可参考!!!
*/
#include<iostream>
using namespace std; template<class T>
void input(T matrix[][]){
cout<<"please input matrix element's data"<<endl;
for(int i = ;i<;i++){
for(int j=;j<;j++){
cin>>matrix[i][j];
}
}
cout<<"input ok";
} template<class T>
void calc(T matrix[][]){
T base_D = matrix[][]*matrix[][]*matrix[][] + matrix[][]*matrix[][]*matrix[][] + matrix[][]*matrix[][]*matrix[][];//计算行列式
base_D = base_D-(matrix[][]*matrix[][]*matrix[][] + matrix[][]*matrix[][]*matrix[][] + matrix[][]*matrix[][]*matrix[][]); if(base_D != ){
T x_D = matrix[][]*matrix[][]*matrix[][] + matrix[][]*matrix[][]*matrix[][] + matrix[][]*matrix[][]*matrix[][];
x_D = x_D-(matrix[][]*matrix[][]*matrix[][] + matrix[][]*matrix[][]*matrix[][] + matrix[][]*matrix[][]*matrix[][]);
T y_D = matrix[][]*matrix[][]*matrix[][] + matrix[][]*matrix[][]*matrix[][] + matrix[][]*matrix[][]*matrix[][];
y_D = y_D-(matrix[][]*matrix[][]*matrix[][] + matrix[][]*matrix[][]*matrix[][] + matrix[][]*matrix[][]*matrix[][]);
T z_D = matrix[][]*matrix[][]*matrix[][] + matrix[][]*matrix[][]*matrix[][] + matrix[][]*matrix[][]*matrix[][];
z_D = z_D-(matrix[][]*matrix[][]*matrix[][] + matrix[][]*matrix[][]*matrix[][] + matrix[][]*matrix[][]*matrix[][]); T x = x_D/base_D;
T y = y_D/base_D;
T z = z_D/base_D;
cout<<"[ x:"<<x<<"; y:"<<y<<"; z:"<<z<<" ]"<<endl;
}else{
cout<<"【无解】";
// return DBL_MIN;
}
}
//计算原理:行列式
int main(){
double matrix[][] ; //三元一次方程组 input<double>(matrix);
calc<double>(matrix);
system("pause");
return ;
}
/*
demo
2x-y+z=10;
3x+2y-z=16;
x+6y-z=28; 2 -1 1 10
3 2 -1 16
1 6 -1 28 output:input ok[ x:4.18182; y:5.09091; z:6.72727 ]
*/

最新文章

  1. python , angular js 学习记录【3】
  2. ASP.Net请求处理机制初步探索之旅 - Part 4 WebForm页面生命周期
  3. Docker使用
  4. PostgreSQL Apt Repository
  5. 关于EF的一个简单Demo
  6. 然并卵,腾讯QQ认证空间又再次关闭申请
  7. Android 样式和主题(style &amp; theme)
  8. (转) Crittercism: 在MongoDB上实现每天数十亿次请求
  9. db2相关问题及解决方法
  10. Factoextra R Package: Easy Multivariate Data Analyses and Elegant Visualization
  11. pandas小记:pandas数据输入输出
  12. web项目中对post请求乱码处理
  13. An Exploration of ARM TrustZone Technology
  14. 逆波兰表达式|2013年蓝桥杯A组题解析第六题-fishers
  15. PHP工厂模式demo
  16. Storm的acker确认机制
  17. BZOJ5467 PKUWC2018Slay the Spire(动态规划)
  18. XSS小游戏通关Writeup
  19. The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. Make s
  20. 使用ffmpeg的av_read_frame,如何控制连接超时

热门文章

  1. Delphi7/2007/2009/2010/XE/XE2/XE3/XE4/XE5/XE6/XE7/XE8/10最终版
  2. CAP定理与BASE理论
  3. nginx-日志统计
  4. mvc 中英文切换
  5. IDEA如何刷新pom文件
  6. windows上搭建nginx
  7. HNOI2017影魔
  8. pip常用命令、配置pip源
  9. POSIX 线程取消点的 Linux 实现
  10. HDU 5608 - function