?? d2r5.cpp
字號:
# include<iomanip.h>
# include<iostream.h>
# include<math.h>
void main()
{
//program d2r5
//driver for routine locate
double x,xx[101];
int i,j,n = 100;
//create array to be searched
for( i = 1; i<=n; i++)
xx[i] = exp(double(i) / 20.0) - 74.0;
cout<<endl;
cout<<"Result of: j=0 indicates x too small"<<endl;
cout<<" j=100 indicates x too large"<<endl;
cout<<endl;
cout<<" locate j xx[j] xx[j+1]"<<endl;
//for test
cout<<setprecision(6)<<setiosflags(ios::fixed);
for( i = 1; i<=19; i++)
{
x = -100.0 + 200.0 * i / 20.0;
locate(xx, n, x, j);
if (j == 0)
{
cout<<setprecision(1)<<setw(8)<<x;
cout<<setprecision(0)<<setw(8)<<j;
cout<<setprecision(6)<<setw(15)<<"lower lim";
cout<<setprecision(6)<<setw(15)<<xx[j + 1]<<endl;
}
else
{
if (j == n )
{
cout<<setprecision(1)<<setw(8)<<x;
cout<<setprecision(0)<<setw(8)<<j;
cout<<setprecision(6)<<setw(15)<<xx[j];
cout<<setprecision(6)<<setw(15)<< "upper lim"<<endl;
}
else
{
cout<<setprecision(1)<<setw(8)<<x;
cout<<setprecision(0)<<setw(8)<<j;
cout<<setprecision(6)<<setw(15)<<xx[j];
cout<<setprecision(6)<<setw(15)<<xx[j + 1]<<endl;
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -