?? d10r11.cpp
字號:
# include<math.h>
# include<iomanip.h>
# include<iostream.h>
# include<stdlib.h>
# include<process.h>
# include<stdio.h>
void main()
{
//program d10r11
//driver for routine zroots
int m,m1,i,j,polish;
m = 4;
m1 = m + 1;
double a[3][6], roots[3][5];
for (j = 1; j<=m1; j++)
{
for (i = 1; i<=2; i++)
{
a[i][j] = 0.0;
}
}
a[2][1] = 2.0;
a[1][3] = -1.0;
a[2][3] = -2.0;
a[1][5] = 1.0;
cout<<endl;
cout<< setw(5)<<"Roots of polynomial x^4-(1+2i)*x^2+2i"<<endl;
cout<<endl;
polish = 0;
zroots(a, m, roots, polish);
cout<< setw(5)<<"Unpolished roots:"<<endl;
cout<< setw(5)<<" root # real imag."<<endl;
cout<<setprecision(4)<<setiosflags(ios::fixed);
for (i = 1 ; i<= m; i++)
{
cout<< setw(5)<< i;
cout<< setw(15)<< roots[1][i];
cout<< setw(15)<< roots[2][i]<<endl;
}
cout<< endl;
cout<< "Corrupted roots:"<<endl;
for (i = 1; i<=m; i++)
{
roots[1][i] = roots[1][i] * (1.0 + 0.01 * i);
roots[2][i] = roots[2][i] * (1.0 + 0.01 * i);
}
cout<< " roots # real imag."<<endl;
for (i = 1; i<=m; i++)
{
cout<< setw(5)<< i;
cout<< setw(15)<< roots[1][i];
cout<< setw(15)<< roots[2][i]<<endl;
}
polish = -1;
zroots(a, m, roots, polish);
cout<< endl;
cout<< "Polished roots:"<<endl;
cout<< " roots # real imag."<<endl;
for (i = 1; i<=m; i++)
{
cout<< setw(5)<< i;
cout<< setw(15)<< roots[1][i];
cout<< setw(15)<< roots[2][i]<<endl;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -