搜索
查看: 157|回复: 0

哪错了?

[复制链接]
 楼主| 发表于 2021-12-24 15:30:48 | 显示全部楼层 |阅读模式
5啊哈币
  1. #include<stdio.h>
  2. int days_in_month(int);
  3. int nth_item(FILE *,int);
  4. main()
  5. {
  6. int heat_deg_days,solar_insol,coldest_mon,heating_reg,efficiency,collect_area,ct,status,next_hdd;
  7. double floor_space,heat_loss,energy_resrc;
  8. FILE *hdd_file;
  9. FILE *solar_file;
  10. hdd_file=fopen("hdd.txt","r");
  11. fscanf(hdd_file,"%d",&heat_deg_days);
  12. coldest_mon=1;
  13. ct=2;
  14. status=fscanf(hdd_file,"%d",&next_hdd);
  15. while(status==1)
  16. {
  17.   if(next_hdd>heat_deg_days)
  18.   {
  19.    heat_deg_days=next_hdd;
  20.    coldest_mon=ct;
  21. }
  22. ++ct;
  23. status=fscanf(hdd_file,"%d",&next_hdd);
  24. }
  25. fclose(hdd_file);


  26. solar_file=fopen("solar.txt","r");
  27. solar_insol=nth_item(solar_file,coldest_mon);
  28. fclose(solar_file);


  29. printf("What is the approximate heating requirement(Btu/");
  30. printf("degree day ft^2)of this type of construction?=>");
  31. scanf("%d",&heating_req);
  32. printf("What percent of solar insolation will be converted");
  33. printf("to usadle heat?=>");
  34. scanf("%d",&efficiency);
  35. printf("What is the floor space(ft^2)?=>");
  36. scanf("%lf",&floor_space);


  37. energy_resrc=efficiency*0.01*solar_insol*days_in_month(coldest_mon);
  38. collect_area=(int)(heat_loss/energy_resrc+0.5);


  39. printf("To replace heat loss of %.0f Btu in the",heat_loss);
  40. printf("coldest month (month %d)with available",coldest_mon);
  41. printf("solar insolation of %d Btu/ft^2/day,",solar_insol);
  42. printf("and anXnefficiency of %d percentf",efficiency);
  43. printf("use a solar collecting area of %d",collect_area);
  44. printf("ft^2.");
  45. return 0;
  46. }
  47. int days_in_month(int month_number)
  48. {
  49. int ans;
  50. switch(month_number)
  51. {
  52.    case2:ans=28;break;
  53.    case4:
  54.    case6:
  55.    case9:
  56.    case11:ans=30;break;
  57.    default:ans=31;
  58. }
  59. return ans;
  60. }
复制代码

楼主新帖
楼主热帖
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

广播台
特别关注
快速回复 返回顶部 返回列表