這期內(nèi)容當(dāng)中小編將會(huì)給大家?guī)碛嘘P(guān)C++中怎么簡化線性代數(shù)矩陣行,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。

成都創(chuàng)新互聯(lián)公司于2013年創(chuàng)立,先為東安等服務(wù)建站,東安等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為東安企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問題。
具體內(nèi)容如下
輸入一個(gè)矩陣,可分別輸出該矩陣的階梯型和最簡型。
輸入僅支持整數(shù),支持分?jǐn)?shù)形式輸出。
媽媽再也不用擔(dān)心俺的線性代數(shù)作業(yè)~
使用實(shí)例:
(實(shí)現(xiàn)格式化輸出部分寫的極為丑陋......)
#include#include#include#include#include#include#define f(i,l,r) for(i=(l);i<=(r);i++)#define ff(i,r,l) for(i=(r);i>=(l);i--)#define ll long long#define EPS 1e-6using namespace std;const int MAXN=105;int n,m;char output[MAXN];string s;struct frac{ int x,y=1; bool operator < (const frac &tmp)const{ return 1.0*x/y<1.0*tmp.x/tmp.y; } frac operator - (const frac &tmp){ frac ans; ans.x=x*tmp.y-y*tmp.x; ans.y=y*tmp.y; ans.sim(); return ans; } frac operator * (const frac &tmp){ frac ans; ans.x=x*tmp.x; ans.y=y*tmp.y; ans.sim(); return ans; } frac operator / (const frac &tmp){ frac ans; ans.x=x*tmp.y; ans.y=y*tmp.x; ans.sim(); return ans; } int gcd(int a,int b){ return b==0?a:gcd(b,a%b); } void sim(){ int d=gcd(x,y); x/=d; y/=d; if(x<0&&y<0){ x=-x; y=-y; } } void write() { int i; char tmp[MAXN]; int num=0; int nx=x,ny=y; s=""; if(!nx){ s+="0"; } else{ if(nx<0||ny<0){ s+='-'; nx=abs(nx); ny=abs(ny); } if(nx%ny==0){ nx/=ny; while(nx){ tmp[++num]='0'+nx%10; nx/=10; } ff(i,num,1){ s+=tmp[i]; } } else{ while(nx){ tmp[++num]='0'+nx%10; nx/=10; } ff(i,num,1){ s+=tmp[i]; } s+='/'; num=0; while(ny){ tmp[++num]='0'+ny%10; ny/=10; } ff(i,num,1){ s+=tmp[i]; } } } f(i,s.length(),7){ cout<<" "; } cout<>n>>m; cout<<"輸入矩陣元素:"<>a[i][j].x; } } gause_1(); cout<<"階梯型為:"<上述就是小編為大家分享的C++中怎么簡化線性代數(shù)矩陣行了,如果剛好有類似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
當(dāng)前題目:C++中怎么簡化線性代數(shù)矩陣行
網(wǎng)頁鏈接:http://www.jiaotiyi.com/article/pohpis.html