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

📄 xpiksr2.cpp

📁 这是C++数值算法(第二版)的源代码,其中包含了目前一些比较常用的数值计算的算法.
💻 CPP
字号:
#include <string>
#include <fstream>
#include <iostream>
#include <iomanip>
#include "nr.h"
#include "print_array.h"
using namespace std;

// Driver for routine piksr2

int main(void)
{
        const int NP=100;
        string txt;
        int i;
        Vec_DP a(NP),b(NP);
        ifstream fp("tarray.dat");

        if (fp.fail())
          NR::nrerror("Data file tarray.dat not found");
        getline(fp,txt);
        for (i=0;i<NP;i++) fp >> a[i];
        // generate b-array
        for (i=0;i<NP;i++) b[i]=i;
        // sort a and mix b
        NR::piksr2(a,b);
        cout << endl << "After sorting a and mixing b, array a is:" << endl;
        cout << fixed << setprecision(2);
        print_array(a,10,7);
        cout << endl << "... and array b is:" << endl;
        print_array(b,10,7);
        cout << "press return to continue ..." << endl;
        cin.get();
        // sort b and mix a
        NR::piksr2(b,a);
        cout << endl << "After sorting b and mixing a, array a is:" << endl;
        print_array(a,10,7);
        cout << endl << "... and array b is:" << endl;
        print_array(b,10,7);
        return 0;
}

⌨️ 快捷键说明

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