?? d2r9.cpp
字號:
# include<iostream.h>
# include<math.h>
# include<iomanip.h>
void main()
{
//program d2r9
//driver for routine polin2
int n,i,j;
double pi,x1,x2,f,dy,y,x1a[6],x2a[6],ya[6][6];
n = 5;
pi = 3.141593;
for (i = 1; i<= n; i++)
{
x1a[i] = i * pi / n;
for (j = 1 ;j<= n;j++)
{
x2a[j] = 1.0* j / n;
ya[i][j] = sin(x1a[i]) * exp(x2a[j]);
}
}
//test 2-dimensional interpolation
cout<<endl;
cout<<" x1 x2 f[x] interpolated error"<<endl;
for (i = 1; i<= 4; i++)
{
x1 = (-0.1 + i / 5.0) * pi;
for (j = 1; j<= 4; j++)
{
x2 = -0.1 + j / 5.0;
f = sin(x1) * exp(x2);
polin2(x1a, x2a, ya, n, n, x1, x2, y, dy);
cout<<setprecision(6)<<setiosflags(ios::fixed);
cout<<setw(11)<<x1;
cout<< setw(11)<<x2;
cout<< setw(11)<<f;
cout<< setw(11)<<y;
cout<< setw(11)<<dy<<endl;
}
cout<<"**********************************"<<endl;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -