C语言程序编写填空!

2025-04-22 22:18:36
推荐回答(2个)
回答1:

void main()
{ int n,fahr,hot,comfort,cold;
double total,ave ;
FILE *fp;
if((fp=___fopen____ ("data.txt","r"))==NULL) //以读方式打开数据文件
{ printf("can not open file!");
exit(0);
}
hot=comfort=cold=0;
total=0; n=0;
while(!feof(fp)) //当文件未读完时
{ //从文件中读入华氏温度 fahr
___fscanf____ (fp,"%d",&fahr);
total=___total____+fahr;
n++;
if(fahr>=90)
hot++;
else if (fahr>=50)
comfort++ ;
else
cold++;
}
ave= total/n ;
printf("hot=%d, comfort =%d,cold =%d, average =%f",hot,comfort,cold,ave);
fclose(___fp____);
}

回答2:

#includeint fun( int x,int y){int i;int z=1; for(i=1;i<=y;i++) z=z*x;return z;}int main(){printf("%d\n",fun(3,2));return 0;}
求采纳为满意回答。