#include<stdio.h>
#include<stdlib.h>
int main()
{
char msg[]={-56,-25,-71,-5,-78,-55,-60,-55,-93,-84,-57,-21,-72,-8,-50,-46,50,48,48,-78,-
58,-72,-69,-93,-95,0};
printf("%s\n\n",msg);
const int N=30;
int rsh[5]={0};
char f1[]="data1.txt",f2[]="data2.txt";
int scores[N],i;
FILE *inf,*outf;
inf=fopen(f1,"r");
outf=fopen(f2,"w");
for(i=0;i<N;i++)
{
fscanf(inf,"%d",&scores[i]);
if(scores[i]>=90)
{
rsh[0]++;
}
else if(scores[i]>=80)
{
rsh[1]++;
}
else if(scores[i]>=70)
{
rsh[2]++;
}
else if(scores[i]>=60)
{
rsh[3]++;
}
else
{
rsh[4]++;
}
}
for(i=0;i<5;i++)
{
fprintf(outf,"%d\t%%%f\n",rsh[i],((float)rsh[i]/N)*100);
}
fclose(inf);
fclose(outf);
system("PAUSE");
return EXIT_SUCCESS;
}
//data1.txt
//88 70 55 64 90 87 72 40 61 58 93 45 77 66 29 61 58 78 77 80 99 82 76 49 81 73 92 87 51 60
温馨提示:答案为网友推荐,仅供参考