fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. // 数据直接写在代码里(国家统计局2020-2022年GDP数据)
  5. int years[3] = {2020, 2021, 2022};
  6. double gdp[3] = {1016098.8, 1143669.7, 1210207.2};
  7.  
  8. printf("年份\tGDP(亿元)\n");
  9. printf("-------------\n");
  10.  
  11. // 循环输出数据
  12. for (int i = 0; i < 3; i++) {
  13. printf("%d\t%.1f\n", years[i], gdp[i]);
  14. }
  15.  
  16. return 0;
  17. }
  18.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
年份	GDP(亿元)
-------------
2020	1016098.8
2021	1143669.7
2022	1210207.2