⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jiangliyuan.cpp

📁 一道例题的vc程序
💻 CPP
字号:
#include<iostream.h>
#include<math.h>
struct A{	             //Definition of a complex number
	double re;
	double im;
};
void initial_A(A a[5][5])//Initialize the matrix a
{
	for(int i=0;i<5;i++){
		for(int j=0;j<5;j++){
			a[i][j].im=0;
			a[i][j].re=0;
		}
	}
}
void output(A a)         //output a complex
{
	if(a.re==0){
		if(a.im>0)
			cout<<"j"<<a.im;
		else if(a.im<0)
			cout<<"-j"<<-a.im;
		else{
			cout<<0<<"      ";
			return;
		}
	}
	else if(a.re!=0){
		if(a.im>0)
			cout<<a.re<<"+j"<<a.im;
		else if(a.im<0)
			cout<<a.re<<"-j"<<-a.im;
		else{
			cout<<a.re;
			return;
		}
	}
}

void main()         //the main function 
{
    cout<<"Please let f equals 3,for I cannot inverse the complex matrix Y,so the matrix Z is not obtained!"<<endl;
	int f;
	cout<<"f=";
	cin>>f;
	cout<<endl;
    A a[5][5];
	initial_A(a);
	a[0][0].im=0.0618;
	a[0][1].re=-0.5882;
	a[1][1].im=0.0314;
	a[1][2].re=-0.4837;
	a[1][3].re=-0.3930;
	a[2][2].im=0.0358;
	a[2][3].re=-0.9321;
	a[3][3].im=0.1144;
	a[3][4].re=-0.6215;
	a[4][4].im=0.1515;
	cout<<"zf=0"<<endl<<endl;
	A If,Z[5][5];
	initial_A(Z);
	Z[3][2].im=0.1611;Z[4][2].im=0.0877;Z[2][2].im=0.1860;Z[1][2].im=0.1533;Z[0][2].im=0.0902;
	//Z[0][2].re=0;Z[1][2].re=0;Z[2][2].re=0;Z[3][2].re=0;Z[4][2].re=0;
	//Z[4][2].re=-0.0006;Z[4][2].im=0.0941;Z[3][2].re=-0.0002;Z[4][2].im=0.1659;
	//Z[2][2].re=0.0090;Z[2][2].im=0.1917;Z[1][2].re=-0.0023;Z[4][2].im=0.1599;
	//Z[0][2].re=-0.0013;Z[0][2].im=0.0896;

	double num=pow(Z[f-1][f-1].re,2)+pow(Z[f-1][f-1].im,2);
	If.re=Z[f-1][f-1].re/num;
	If.im=-Z[f-1][f-1].im/num;
	A V[5];
	for(int k=0;k<5;k++)
	{
		V[k].re=1-(Z[f-1][f-1].re,2*Z[k][f-1].re+Z[f-1][f-1].im*Z[k][f-1].im)/num;
        V[k].im=-(Z[f-1][f-1].re*Z[k][f-1].im+Z[f-1][f-1].im*Z[k][f-1].re)/num;
	}
	A I54,I43,I23,I12,I24;
    I54.re=(V[4].im-V[3].im)/0.184;
	I54.im=-(V[4].re-V[3].re)/0.184;
    I43.re=(V[3].im-V[2].im)/0.05;
	I43.im=-(V[3].re-V[2].re)/0.05;
	I23.re=(V[1].im-V[2].im)/0.065;
	I23.im=-(V[1].re-V[2].re)/0.065;
	I12.re=(V[0].im-V[1].im)/0.105;
	I12.im=-(V[0].re-V[1].re)/0.105;
	I24.re=(V[1].im-V[3].im)/0.08;
	I24.im=-(V[1].re-V[3].re)/0.08;
	//output of Z
	cout<<"Y=\n";
	for(int i=0;i<5;i++){
		for(int j=0;j<5;j++){
			output(a[i][j]);
			cout<<"     ";
		}
		cout<<endl;
	}
	cout<<endl;
	//output of If
	cout<<"I"<<f<<"=";output(If);cout<<endl<<endl;
	//output of V
	for(k=0;k<5;k++){
		cout<<"V"<<k+1<<"=";
		output(V[k]);
		cout<<endl;
	}
    cout<<endl;
	//output of I
	cout<<"I54=";output(I54);cout<<endl;
	cout<<"I43=";output(I43);cout<<endl;
	cout<<"I23=";output(I23);cout<<endl;
	cout<<"I12=";output(I12);cout<<endl;
	cout<<"I24=";output(I24);cout<<endl;
}

	
	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -