?? d1r7.cpp
字號:
#include "iostream.h"
#include "math.h"
void main()
{
//program d1r7
//driver program for routine toeplz
int i,j,n2,n = 5;
double sum1;
n2 = 2 * n;
double x[6], y[6], r[11];
//輸入已知的方程組的系數矩陣的r
for (i = 1; i<=2 * n - 1; i++)
{
r[i] = 1 / double(i);
}
//輸入已知的方程組的右端向量
for (i = 1; i<=n; i++)
{
y[i] = 0.1 * i;
}
cout.setf(ios::fixed|ios::right);
cout.precision(5);
cout<<"已知的方程組的右端向量"<<endl;
cout.width(12); cout<<y[1]<<endl;
cout.width(12); cout<<y[2]<<endl;
cout.width(12); cout<<y[3]<<endl;
cout.width(12); cout<<y[4]<<endl;
cout.width(12); cout<<y[5]<<endl;
toeplz(r, x, y, n);
//輸出方程組的解x
cout<<endl;
cout<<"計算出的方程組的解"<<endl;
cout.width(15); cout<<x[1]<<endl;
cout.width(15); cout<<x[2]<<endl;
cout.width(15); cout<<x[3]<<endl;
cout.width(15); cout<<x[4]<<endl;
cout.width(15); cout<<x[5]<<endl;
//將計算出的解x乘以系數矩陣,以驗證計算結果正確
cout<<endl;
cout<<"將計算出的解乘以系數矩陣,以驗證計算結果正確"<<endl;
cout<<endl;
cout<<"解乘以系數矩陣"<<" "<<"方程組的右端向量"<<endl;
for (i = 1; i<=n; i++)
{
sum1 = 0;
for (j = 1; j<=n; j++)
{
sum1 = sum1 + r[n + i - j] * x[j];
}
cout<<" "<<sum1<<" "<<y[i]<<endl;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -