啊哈磊_编程从这里起步
标题:
哪错了?
[打印本页]
作者:
0000asdf
时间:
2021-12-24 15:30
标题:
哪错了?
#include<stdio.h>
int days_in_month(int);
int nth_item(FILE *,int);
main()
{
int heat_deg_days,solar_insol,coldest_mon,heating_reg,efficiency,collect_area,ct,status,next_hdd;
double floor_space,heat_loss,energy_resrc;
FILE *hdd_file;
FILE *solar_file;
hdd_file=fopen("hdd.txt","r");
fscanf(hdd_file,"%d",&heat_deg_days);
coldest_mon=1;
ct=2;
status=fscanf(hdd_file,"%d",&next_hdd);
while(status==1)
{
if(next_hdd>heat_deg_days)
{
heat_deg_days=next_hdd;
coldest_mon=ct;
}
++ct;
status=fscanf(hdd_file,"%d",&next_hdd);
}
fclose(hdd_file);
solar_file=fopen("solar.txt","r");
solar_insol=nth_item(solar_file,coldest_mon);
fclose(solar_file);
printf("What is the approximate heating requirement(Btu/");
printf("degree day ft^2)of this type of construction?=>");
scanf("%d",&heating_req);
printf("What percent of solar insolation will be converted");
printf("to usadle heat?=>");
scanf("%d",&efficiency);
printf("What is the floor space(ft^2)?=>");
scanf("%lf",&floor_space);
energy_resrc=efficiency*0.01*solar_insol*days_in_month(coldest_mon);
collect_area=(int)(heat_loss/energy_resrc+0.5);
printf("To replace heat loss of %.0f Btu in the",heat_loss);
printf("coldest month (month %d)with available",coldest_mon);
printf("solar insolation of %d Btu/ft^2/day,",solar_insol);
printf("and anXnefficiency of %d percentf",efficiency);
printf("use a solar collecting area of %d",collect_area);
printf("ft^2.");
return 0;
}
int days_in_month(int month_number)
{
int ans;
switch(month_number)
{
case2:ans=28;break;
case4:
case6:
case9:
case11:ans=30;break;
default:ans=31;
}
return ans;
}
复制代码
欢迎光临 啊哈磊_编程从这里起步 (https://bbs.codeaha.com/)
Powered by Discuz! X3.2