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

📄 d9r6.cpp

📁 使用VC++编写的大量数学算法的源代码
💻 CPP
字号:
#include "iostream.h"

void fpoly(double x, double p[], int np)
{
	p[1] = 1.0;
	for (int j = 2; j<=np; j++)
	{
		p[j] = p[j - 1] * x;
	}
}

void main()
{
    //program d9r6
    //driver for routine fpoly
    int nval = 15;
    double dx = 0.1;
    int npoly = 5;
    double afunc[6];
	double x;
    cout<<"                   Powers of x"<<endl;
    cout<<endl;
    cout<<"   x    x^0       x^1      x^2       x^3      x^4"<<endl;
	cout.setf(ios::left);
    for (int i = 1; i<=nval; i++)
	{
        x =i * dx;
        fpoly(x, afunc, npoly);
		cout<<"  ";
		cout.width(7);
        cout<<x;
        for (int j = 1; j<=npoly; j++)
		{
			cout.width(9);
            cout<<afunc[j];
        }
        cout<<endl;
    }
}

⌨️ 快捷键说明

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