刚接触c,不知道下面的程序如何修改,求教各位大神修改,谢谢!
#include<stdio.h>
#define N 6
typedef struct yonghu
{
long huhao;
int shuihao;
int dianhao;
}yonghu[N];
void main()
{
FILE*fp;
int i;
long shuihao,dianhao;
float shuihaop,dianhaop,sdp;
float shuip[6],dianp[6],shui,dian,sum[6];
fp=fopen("input.dat","wb");
printf("输入水和电的价格\n");
scanf("%f %f",&shui,&dian);
getchar();
fprintf(fp,"%.lf",shui);
fprintf(fp,"%.lf",dian);
printf("输入用户的信息\n");
for(i=0;i<6;i++)
{
scanf("%ld %d %d",&yonghu[i].huhao,&yonghu[i].shuihao,&yonghu[i].dianhao);
getchar();
fprintf(fp,"%d%d%d\n",yonghu[i].huhao,yonghu[i].shuihao,yonghu[i].dianhao);
}
for(i=0;i<6;i++)
{
shuip[i]=yonghu[i].shuihao*shuihao;
dianp[i]=yonghu[i].dianhao*dianhao;
sum[i]=shuip[i]+dianp[i];
shuihaop+=shuip[i];
dianhaop+=dianp[i];
shuihao+=yonghu[i].shuihao;
dianhao+=yonghu[i].dianhao;
}
fp=fopen("charge.dat","w");
fputs("address shui(T) shuipay(Y) electric dianpay(Y) sum(Y)\n",fp);
for(i=0;i<6;i++)
{
fprintf("%ld%d%.lf%d%.lf%.lf\n",yonghu[i].huhao,yonghu[i].shuihao,shuip[i],yonghu[i].dianhao,dianp[i],sum[i]);
}
fputs("total",fp);
fprintf("%ld%.lf%d%.lf%.lf",shuihao,shuip,dianhao,dianp,sdp);
fclose(fp);
getch();
}