⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 d2r11.cpp

📁 Visual C++ 常用数值算法集 源代码
💻 CPP
字号:
# include<iostream.h>
# include<math.h>
# include<iomanip.h>

void main()
{
    //program d2r11
    //driver for routine splin2
	int m,n,i,j;
    double x1[11],x2[11],y[11][11],y2[11][11],x1x2,xx1,xx2,ff,f;
	m = 10;
    n = 10;
	f = 0.0;
    for (i = 1; i<=m; i++)
        x1[i] = 0.2 * i;
    for (i = 1; i<=n; i++)
        x2[i] = 0.2 * i;
    
    for (i = 1; i<=m; i++)
	{
        for (j = 1; j<=n; j++)
		{
            x1x2 = x1[i] * x2[j];
            y[i][j] = x1x2 * exp(-x1x2);
        }
    }
    splie2(x1, x2, y, m, n, y2);
    cout<<endl;
    cout<<"        x1           x2         splin2       actual"<<endl;
    for (i = 1; i<=m; i++) 
	{
        xx1 = 0.1 * i;
        xx2 = xx1*xx1;
        splin2(x1, x2, y, y2, m, n, xx1, xx2, f);
        x1x2 = xx1 * xx2;
        ff = x1x2 * exp(-x1x2);
		cout<<setprecision(6)<<setiosflags(ios::fixed);
        cout<<setw(13)<<xx1;
        cout<<setw(13)<<xx2;
        cout<<setw(13)<<f;
        cout<<setw(13)<<ff<<endl;
    }
}   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -