软件模拟中美gdp今后几年的变化情况

                                       软件模拟中美gdp

 

以2018年的实际增速为基准,推演今后几年的中美gpd总量对比。

2018年中美GDP总量:

美国 205130.00万亿美元
中国 134572.67万亿美元

2018年GDP增速:

美国 2.86%
中国 6.6%

 

简单写个程序:

#include 

#define GDP_ORIGINAL_US 205130.00
#define GDP_ORIGINAL_CHINA 134572.67

#define GDP_RATE_US 2.86
#define GDP_RATE_CHINA 6.6

int main(){
        int current_year = 2018;
        double us_gdp = GDP_ORIGINAL_US;
        double china_gdp = GDP_ORIGINAL_CHINA;

        int i = 1;
        for(i = 1; i < 50; i++){
                us_gdp = us_gdp*(1+GDP_RATE_US*0.01);
                china_gdp = china_gdp*(1+GDP_RATE_CHINA*0.01);
                if( us_gdp < china_gdp ){
                        printf("\n\n---------------------------------------\n");
                }
                printf(" year %d: US_GDP = %.3lf, CHINA_GDP = %.3lf \n", current_year+i, us_gdp, china_gdp);
                if( us_gdp < china_gdp ){
                        printf("---------------------------------------\n");
                        break;
                }

        }
}

运行结果:

root@ubuntu:~/jack# gcc -o test test.c 
root@ubuntu:~/jack# ./test 
 year 2019: US_GDP = 210996.718, CHINA_GDP = 143454.466 
 year 2020: US_GDP = 217031.224, CHINA_GDP = 152922.461 
 year 2021: US_GDP = 223238.317, CHINA_GDP = 163015.343 
 year 2022: US_GDP = 229622.933, CHINA_GDP = 173774.356 
 year 2023: US_GDP = 236190.149, CHINA_GDP = 185243.464 
 year 2024: US_GDP = 242945.187, CHINA_GDP = 197469.532 
 year 2025: US_GDP = 249893.420, CHINA_GDP = 210502.521 
 year 2026: US_GDP = 257040.371, CHINA_GDP = 224395.688 
 year 2027: US_GDP = 264391.726, CHINA_GDP = 239205.803 
 year 2028: US_GDP = 271953.329, CHINA_GDP = 254993.386 
 year 2029: US_GDP = 279731.195, CHINA_GDP = 271822.950 


---------------------------------------
 year 2030: US_GDP = 287731.507, CHINA_GDP = 289763.264 
---------------------------------------

正如专家所料,2030年,中国将在gdp总量上第一次超过美国,成为世界第一经济大国!

你可能感兴趣的:(生活实践)