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

📄 xkendl1.cpp

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

// Driver for routine kendl1

int main(void)
{
        const int NDAT=200;
        const string txt[5]={"RAN0","RAN1","RAN2","RAN3","RAN4"};
        int i,j;
        DP prob,tau,z;
        Vec_DP data1(NDAT),data2(NDAT);

        // Look for correlations in RAN0, RAN1, RAN2, RAN3 and RAN4
        cout << endl << "Pair correlations of RAN0 ... RAN4" << endl << endl;
        cout << setw(9) << "Program" << setw(18) << "Kendall tau";
        cout << setw(17) << "Deviation" << setw(19) << "Probability" << endl;
        cout << fixed << setprecision(6);
        for (i=0;i<5;i++) {
          int idum=(-1357);
          for (j=0;j<NDAT;j++) {
            if (i == 0) {
              data1[j]=NR::ran0(idum);
              data2[j]=NR::ran0(idum);
            } else if (i == 1) {
              data1[j]=NR::ran1(idum);
              data2[j]=NR::ran1(idum);
            } else if (i == 2) {
              data1[j]=NR::ran2(idum);
              data2[j]=NR::ran2(idum);
            } else if (i == 3) {
              data1[j]=NR::ran3(idum);
              data2[j]=NR::ran3(idum);
            } else if (i == 4) {
              data1[j]=NR::ran4(idum);
              data2[j]=NR::ran4(idum);
            }
          }
          NR::kendl1(data1,data2,tau,z,prob);
          cout << setw(8) << txt[i] << setw(18) << tau;
          cout << setw(18) << z << setw(18) << prob << endl;
        }
        return 0;
}

⌨️ 快捷键说明

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