这个程序怎么求不了和
#include<stdio.h> #include <stdlib.h>
int main()
{
FILE *input,*charge;
float a,b;
int i;
struct
{
int num;
int count1;
int count2;
float sum;
}id[6];
input=fopen("input.dat","r+");
if(input == NULL)
{
printf("Open file error!\n");
return 1;
}
fscanf(input,"%f%f",&a,&b);
printf("NO.\tcount1\tcount2\n");
for(i=0;i<6;i++)
{
fscanf(input,"%d%d%d",&id[i].num,&id[i].count1,&id[i].count2);
printf("%d \t %d \t %d\n",id[i].num,id[i].count1,id[i].count2);
}
fclose(input);
charge=fopen("charge.dat","a+");
if(charge == NULL)
{
printf("Open file error!\n");
return 1;
}
fputs("NO.",charge);
fputs("\tmoney1\tmoney2\tsum\n",charge);
for(i=0;i<6;i++)
{
fprintf(charge,"%d \t %.1f \t %.1f \t%.1f \n",id[i].num,id[i].count1*a,id[i].count2*b,id[i].count1*a+id[i].count2*b);
}
}