标签:
1 #include<stdio.h> 2 #include<stdlib.h> 3 4 int main() 5 { 6 FILE *fp_read, *fp_write; 7 int i,j,k,l; 8 float avg; 9 fopen_s(&fp_read,"E:\\score.txt","r"); 10 fopen_s(&fp_write,"E:\\average.txt","w"); 11 12 while(!feof(fp_read)) 13 { 14 fscanf(fp_read,"%d %d %d %d",&i,&j,&k,&l); 15 avg = (float)(i + j + k + l) / 4; 16 fprintf(fp_write,"%3d %3d %3d %3d %.2f",i,j,k,l,avg); 17 fputc(‘\n‘,fp_write); 18 } 19 20 fclose(fp_read); 21 fclose(fp_write); 22 23 system("pause"); 24 return 0; 25 }
标签:
原文地址:http://www.cnblogs.com/cpsmile/p/4776875.html