📄 cpp1.cpp
字号:
#include"Matrix.h"
#include<iostream.h>
#include<fstream.h>
void main(){
double deltaX=l/N; //棒的每一份的长度
double alpha=(deltaT*K)/(deltaX*deltaX*rou*Crou);
double beta=deltaX*h/K;
double temp_a[N];
for(int j=0;j<=N-1-1;j++){
temp_a[j]=-alpha;
}
temp_a[N-1]=-1;
double temp_b[N+1];
temp_b[0]=1+beta;
for(j=1;j<=N-1;j++){
temp_b[j]=1+(2*alpha);
}
temp_b[N]=1+beta;
double temp_c[N];
temp_c[0]=-1;
for(j=1;j<=N-1;j++){
temp_c[j]=-alpha;
}
double temp_f[N+1];
temp_f[0]=beta*T_infinite;
temp_f[N]=beta*T_infinite;
for(j=1;j<=N-1;j++){
temp_f[j]=T0;
}
A matrixA(N+1);
matrixA.setA(temp_a,temp_b,temp_c,temp_f);
double comp=1000000;
int count=0;
while((comp-T_infinite)>0.001){
matrixA.getLU();
matrixA.getY();
comp=matrixA.getX();
matrixA.changef();
matrixA.show();
count=count+100;
ofstream ofile("compute.txt",ios::app);
ofile<<"用时"<<count<<"秒"<<endl;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -