zoukankan      html  css  js  c++  java
  • 风景区的面积及道路状况分析问题 test

    参考文献:   https://wenku.baidu.com/view/b6aed86baf1ffc4ffe47ac92.html

    #include <bits/stdc++.h>
    using namespace std;
    const int maxn = 100;
    
    double a[maxn][maxn];
    
    int main ()
    {
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
        int n = 19;
        //int s = 0 ,t = 1,x;
        //输入x 以及 y 的值
        for(int i=0 ; i < n ; i++){
            for(int j=0 ; j < 2 ; j++){
                cin >> a[i][j];
            }
        }// 读入数据
    
    
        for(int j=1 ; j < n+1 ; j++){
            for(int i=j ; i < n ; i++){
                a[i][j+1] = 1.0* (a[i][j] - a[i-1][j]) / (a[i][0] - a[i-j][0]);// + 0.00500000005;
            }
        }// 计算均差
    
        printf("输出xi,yi及各阶均差
    ");
        printf("  Xi f(xi)
    ");
        for(int i=0 ; i < n ; i++){
            cout << i << " ";
            for(int j=0 ; j < i+2 ; j++){
                printf("%11.10lf  ",a[i][j]);
            }
            cout << endl;
        }// 打印均差表
    
        printf("输出牛顿插值表达式
    ");
        printf("F%d(x)=
    ",n);
        for(int i=0 ; i < n ; i++)
        {
            if(i)
                printf("+ ");
            printf("%11.10lf",a[i][i+1]);
            for(int j=0 ; j < i ; j++)
                printf("(x-%3.2lf)",a[j][0]);
            if(i == n)
                break;
            cout<< endl;
        }
        printf("
    ");
    }
    牛顿插值法
    0.1
    6.54
    4.76
    5.19
    6.65
    4.53
    9.51
    4.99
    12.17
    2.21
    15.23
    6.81
    17.35
    6.10
    19.21
    8.89
    22.15
    4.88
    23.46
    3.72
    27.11
    3.21
    28.81
    2.78
    29.87
    3.58
    30.52
    2.28
    30.99
    2.11
    32.01
    2.47
    33.85
    2.26
    34.91
    1.55
    37.5
    6
    样例输入1
    1.7
    19.89
    4.80
    24.52
    5.98    
    34.82    
    8.83
    40.54
    12.18
    37.67
    15.21
    41.38
    17.92
    30.00
    19.50
    19.68
    22.23
    14.56
    24.56
    18.86
    27.31
    17.98
    29.11
    21.62
    29.87
    17.98
    30.87
    14.86
    31.51
    12.86
    32.89
    10.96
    33.78
    8.68
    35.71
    9.54
    37.5
    6
    样例输入2
    输出xi,yi及各阶均差
      Xi f(xi)
    0 0.1000000000  6.5400000000  
    1 4.7600000000  5.1900000000  -0.2896995708  
    2 6.6500000000  4.5300000000  -0.3492063492  -0.0090850043  
    3 9.5100000000  4.9900000000  0.1608391608  0.1073780021  0.0123765150  
    4 12.1700000000  2.2100000000  -1.0451127820  -0.2184695549  -0.0439740293  -0.0046686449  
    5 15.2300000000  6.8100000000  1.5032679739  0.4455211112  0.0773881895  0.0115914249  0.0010746907  
    6 17.3500000000  6.1000000000  -0.3349056604  -0.3548597749  -0.1020893987  -0.0167736064  -0.0022529810  -0.0001929085  
    7 19.2100000000  8.8900000000  1.5000000000  0.4610315730  0.1158936574  0.0224724800  0.0031246884  0.0003721571  0.0000295691  
    8 22.1500000000  4.8800000000  -1.3639455782  -0.5966553288  -0.1528449280  -0.0269277140  -0.0039082432  -0.0004537375  -0.0000474925  -0.0000034949  
    9 23.4600000000  3.7200000000  -0.8854961832  0.1125763282  0.1160771943  0.0326758350  0.0052793223  0.0006586068  0.0000661716  0.0000060783  0.0000004098  
    10 27.1100000000  3.2100000000  -0.1397260274  0.1503568863  0.0047823491  -0.0114031604  -0.0037103531  -0.0006017186  -0.0000716094  -0.0000067342  -0.0000005733  -0.0000000364  
    11 28.8100000000  2.7800000000  -0.2529411765  -0.0211617101  -0.0257535430  -0.0031808221  0.0007174815  0.0003260556  0.0000557557  0.0000065992  0.0000006017  0.0000000489  0.0000000030  
    12 29.8700000000  3.5800000000  0.7547169811  0.3650935354  0.0602582286  0.0111414212  0.0013435500  0.0000500055  -0.0000188559  -0.0000042153  -0.0000005312  -0.0000000488  -0.0000000039  -0.0000000002  
    13 30.5200000000  2.2800000000  -2.0000000000  -1.6109456030  -0.5794836183  -0.0906149925  -0.0121572776  -0.0011937071  -0.0000944353  -0.0000049431  -0.0000000397  0.0000000234  0.0000000030  0.0000000003  0.0000000000  
    14 30.9900000000  2.1100000000  -0.3617021277  1.4627659574  1.4099594314  0.5127430540  0.0801272306  0.0104394240  0.0009875324  0.0000793231  0.0000053468  0.0000002862  0.0000000122  0.0000000004  0.0000000000  -0.0000000000  
    15 32.0100000000  2.4700000000  0.3529411765  0.4796263786  -0.4594110181  -0.5841782655  -0.2238614938  -0.0355542368  -0.0046646715  -0.0004415784  -0.0000355322  -0.0000024362  -0.0000001372  -0.0000000066  -0.0000000003  -0.0000000000  -0.0000000000  
    16 33.8500000000  2.2600000000  -0.1141304348  -0.1633117522  -0.1930745138  0.0669187197  0.1291859098  0.0523809204  0.0084634415  0.0011220609  0.0001068060  0.0000086266  0.0000005941  0.0000000337  0.0000000017  0.0000000001  0.0000000000  0.0000000000  
    17 34.9100000000  1.5500000000  -0.6698113208  -0.1916140986  -0.0072199863  0.0423358832  -0.0048775469  -0.0219776158  -0.0095331457  -0.0015717543  -0.0002111140  -0.0000202497  -0.0000016444  -0.0000001137  -0.0000000065  -0.0000000003  -0.0000000000  -0.0000000000  -0.0000000000  
    18 37.5000000000  6.0000000000  1.7181467181  0.6542350792  0.1540708885  0.0247758640  -0.0025157621  0.0003095393  0.0025646899  0.0011643730  0.0001948809  0.0000264492  0.0000025532  0.0000002083  0.0000000145  0.0000000008  0.0000000000  0.0000000000  0.0000000000  0.0000000000  
    输出牛顿插值表达式
    F19(x)=
    6.5400000000
    + -0.2896995708(x-0.10)
    + -0.0090850043(x-0.10)(x-4.76)
    + 0.0123765150(x-0.10)(x-4.76)(x-6.65)
    + -0.0046686449(x-0.10)(x-4.76)(x-6.65)(x-9.51)
    + 0.0010746907(x-0.10)(x-4.76)(x-6.65)(x-9.51)(x-12.17)
    + -0.0001929085(x-0.10)(x-4.76)(x-6.65)(x-9.51)(x-12.17)(x-15.23)
    + 0.0000295691(x-0.10)(x-4.76)(x-6.65)(x-9.51)(x-12.17)(x-15.23)(x-17.35)
    + -0.0000034949(x-0.10)(x-4.76)(x-6.65)(x-9.51)(x-12.17)(x-15.23)(x-17.35)(x-19.21)
    + 0.0000004098(x-0.10)(x-4.76)(x-6.65)(x-9.51)(x-12.17)(x-15.23)(x-17.35)(x-19.21)(x-22.15)
    + -0.0000000364(x-0.10)(x-4.76)(x-6.65)(x-9.51)(x-12.17)(x-15.23)(x-17.35)(x-19.21)(x-22.15)(x-23.46)
    + 0.0000000030(x-0.10)(x-4.76)(x-6.65)(x-9.51)(x-12.17)(x-15.23)(x-17.35)(x-19.21)(x-22.15)(x-23.46)(x-27.11)
    + -0.0000000002(x-0.10)(x-4.76)(x-6.65)(x-9.51)(x-12.17)(x-15.23)(x-17.35)(x-19.21)(x-22.15)(x-23.46)(x-27.11)(x-28.81)
    + 0.0000000000(x-0.10)(x-4.76)(x-6.65)(x-9.51)(x-12.17)(x-15.23)(x-17.35)(x-19.21)(x-22.15)(x-23.46)(x-27.11)(x-28.81)(x-29.87)
    + -0.0000000000(x-0.10)(x-4.76)(x-6.65)(x-9.51)(x-12.17)(x-15.23)(x-17.35)(x-19.21)(x-22.15)(x-23.46)(x-27.11)(x-28.81)(x-29.87)(x-30.52)
    + -0.0000000000(x-0.10)(x-4.76)(x-6.65)(x-9.51)(x-12.17)(x-15.23)(x-17.35)(x-19.21)(x-22.15)(x-23.46)(x-27.11)(x-28.81)(x-29.87)(x-30.52)(x-30.99)
    + 0.0000000000(x-0.10)(x-4.76)(x-6.65)(x-9.51)(x-12.17)(x-15.23)(x-17.35)(x-19.21)(x-22.15)(x-23.46)(x-27.11)(x-28.81)(x-29.87)(x-30.52)(x-30.99)(x-32.01)
    + -0.0000000000(x-0.10)(x-4.76)(x-6.65)(x-9.51)(x-12.17)(x-15.23)(x-17.35)(x-19.21)(x-22.15)(x-23.46)(x-27.11)(x-28.81)(x-29.87)(x-30.52)(x-30.99)(x-32.01)(x-33.85)
    + 0.0000000000(x-0.10)(x-4.76)(x-6.65)(x-9.51)(x-12.17)(x-15.23)(x-17.35)(x-19.21)(x-22.15)(x-23.46)(x-27.11)(x-28.81)(x-29.87)(x-30.52)(x-30.99)(x-32.01)(x-33.85)(x-34.91)
    样例输出一
    输出xi,yi及各阶均差
      Xi f(xi)
    0 1.70  19.89  
    1 4.80  24.52  1.49  
    2 5.98  34.82  8.73  1.69  
    3 8.83  40.54  2.01  -1.67  -0.47  
    4 12.18  37.67  -0.86  -0.46  0.16  0.06  
    5 15.21  41.38  1.22  0.33  0.09  -0.01  -0.01  
    6 17.92  30.00  -4.20  -0.94  -0.14  -0.02  -0.00  0.00  
    7 19.50  19.68  -6.53  -0.54  0.05  0.02  0.00  0.00  -0.00  
    8 22.23  14.56  -1.88  1.08  0.23  0.02  -0.00  -0.00  -0.00  -0.00  
    9 24.56  18.86  1.85  0.74  -0.05  -0.03  -0.00  -0.00  -0.00  0.00  0.00  
    10 27.31  17.98  -0.32  -0.43  -0.15  -0.01  0.00  0.00  0.00  0.00  0.00  -0.00  
    11 29.11  21.62  2.02  0.51  0.14  0.03  0.00  0.00  -0.00  -0.00  -0.00  -0.00  -0.00  
    12 29.87  17.98  -4.79  -2.66  -0.60  -0.10  -0.01  -0.00  -0.00  -0.00  -0.00  0.00  0.00  0.00  
    13 30.87  14.86  -3.12  0.95  1.01  0.26  0.04  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  
    14 31.51  12.86  -3.12  -0.00  -0.40  -0.34  -0.09  -0.01  -0.00  -0.00  -0.00  -0.00  -0.00  -0.00  -0.00  -0.00  
    15 32.89  10.96  -1.38  0.87  0.29  0.18  0.09  0.02  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  
    16 33.78  8.68  -2.56  -0.52  -0.48  -0.20  -0.08  -0.03  -0.01  -0.00  -0.00  -0.00  -0.00  -0.00  -0.00  -0.00  -0.00  -0.00  
    17 35.71  9.54  0.45  1.07  0.38  0.18  0.06  0.02  0.01  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  
    18 37.50  6.00  -1.98  -0.65  -0.37  -0.13  -0.05  -0.01  -0.00  -0.00  -0.00  -0.00  -0.00  -0.00  -0.00  -0.00  -0.00  -0.00  -0.00  -0.00  
    输出牛顿插值表达式
    F19(x)=
    19.89
    + 1.49(x-1.70)
    + 1.69(x-1.70)(x-4.80)
    + -0.47(x-1.70)(x-4.80)(x-5.98)
    + 0.06(x-1.70)(x-4.80)(x-5.98)(x-8.83)
    + -0.01(x-1.70)(x-4.80)(x-5.98)(x-8.83)(x-12.18)
    + 0.00(x-1.70)(x-4.80)(x-5.98)(x-8.83)(x-12.18)(x-15.21)
    + -0.00(x-1.70)(x-4.80)(x-5.98)(x-8.83)(x-12.18)(x-15.21)(x-17.92)
    + -0.00(x-1.70)(x-4.80)(x-5.98)(x-8.83)(x-12.18)(x-15.21)(x-17.92)(x-19.50)
    + 0.00(x-1.70)(x-4.80)(x-5.98)(x-8.83)(x-12.18)(x-15.21)(x-17.92)(x-19.50)(x-22.23)
    + -0.00(x-1.70)(x-4.80)(x-5.98)(x-8.83)(x-12.18)(x-15.21)(x-17.92)(x-19.50)(x-22.23)(x-24.56)
    + -0.00(x-1.70)(x-4.80)(x-5.98)(x-8.83)(x-12.18)(x-15.21)(x-17.92)(x-19.50)(x-22.23)(x-24.56)(x-27.31)
    + 0.00(x-1.70)(x-4.80)(x-5.98)(x-8.83)(x-12.18)(x-15.21)(x-17.92)(x-19.50)(x-22.23)(x-24.56)(x-27.31)(x-29.11)
    + 0.00(x-1.70)(x-4.80)(x-5.98)(x-8.83)(x-12.18)(x-15.21)(x-17.92)(x-19.50)(x-22.23)(x-24.56)(x-27.31)(x-29.11)(x-29.87)
    + -0.00(x-1.70)(x-4.80)(x-5.98)(x-8.83)(x-12.18)(x-15.21)(x-17.92)(x-19.50)(x-22.23)(x-24.56)(x-27.31)(x-29.11)(x-29.87)(x-30.87)
    + 0.00(x-1.70)(x-4.80)(x-5.98)(x-8.83)(x-12.18)(x-15.21)(x-17.92)(x-19.50)(x-22.23)(x-24.56)(x-27.31)(x-29.11)(x-29.87)(x-30.87)(x-31.51)
    + -0.00(x-1.70)(x-4.80)(x-5.98)(x-8.83)(x-12.18)(x-15.21)(x-17.92)(x-19.50)(x-22.23)(x-24.56)(x-27.31)(x-29.11)(x-29.87)(x-30.87)(x-31.51)(x-32.89)
    + 0.00(x-1.70)(x-4.80)(x-5.98)(x-8.83)(x-12.18)(x-15.21)(x-17.92)(x-19.50)(x-22.23)(x-24.56)(x-27.31)(x-29.11)(x-29.87)(x-30.87)(x-31.51)(x-32.89)(x-33.78)
    + -0.00(x-1.70)(x-4.80)(x-5.98)(x-8.83)(x-12.18)(x-15.21)(x-17.92)(x-19.50)(x-22.23)(x-24.56)(x-27.31)(x-29.11)(x-29.87)(x-30.87)(x-31.51)(x-32.89)(x-33.78)(x-35.71)
    样例输出二
  • 相关阅读:
    简单的实现了利用plist进行大图分割小图
    windows 10升级后系统盘清理
    在window下用编译lua源文件生成lua程序
    window下ip切换
    springMVC对简单对象、Set、List、Map的数据绑定和常见问题.
    MIME类型大全
    Apache poi 固定Excel 表格导入数据库方法(列名对应数据库字段名)
    java 通过Apache poi导出excel代码demo实例
    mySQL 开启事件存储过程
    Mysql 变量讲解
  • 原文地址:https://www.cnblogs.com/Draymonder/p/7339261.html
Copyright © 2011-2022 走看看