user-0 提问: 求助，程序输出界面是空白的，而且得到的student2.txt也是是空白的，是哪里 有错误吗？

回复:
user: user-0
content: 引用 1 楼 自信男孩的回复:#include <stdio.h> #include <stdlib.h>  struct student {     long num;     char name[10];     float score[3]; }ml[10];  void mr(float aver[],int rank[]) {     int i,j,a;     for(i=0;i<10;i++)     {         a=1;         for(j=0;j<10;j++)         {             if(aver[i]<aver[j])                 a=a+1;         }         rank[i]=a;     } } int main() {     FILE *fp1,*fp2;     int i,rank[10];     float aver[10];     if((fp1=fopen("E:\\student1.txt","r"))==NULL)     {         printf("无法打开文件\n");         exit(0);     }     fp2 = fopen("E:\\student2.txt","w");     if (!fp2) {         printf("无法打开文件\n");         exit(0);     }  #if 0     for(i=0;i<10;i++)         //fscanf(fp1,"%ld %s %f %f %f",ml[i].num,ml[i].name,ml[i].score[0],ml[i].score[1],ml[i].score[2]);         fscanf(fp1,"%ld %s %f %f %f", &ml[i].num,ml[i].name, &ml[i].score[0], &ml[i].score[1], &ml[i].score[2]);     for(i=0;i<10;i++)     {         aver[i]=(ml[i].score[0]+ml[i].score[1]+ml[i].score[2])/3.0;     } #else     for(i=0;i<10;i++) {         //fscanf(fp1,"%ld %s %f %f %f",ml[i].num,ml[i].name,ml[i].score[0],ml[i].score[1],ml[i].score[2]);         fscanf(fp1,"%ld %s %f %f %f", &ml[i].num,ml[i].name, &ml[i].score[0], &ml[i].score[1], &ml[i].score[2]);         aver[i] = (ml[i].score[0]+ml[i].score[1]+ml[i].score[2])/3.0;     } #endif     mr(aver,rank);     for(i=0;i<10;i++)         fprintf(fp2,"%-9ld%-10s%-5.1f%-5.1f%-8.1f%-10.1f%-d\n",ml[i].num,ml[i].name,ml[i].score[0],ml[i].score[1],ml[i].score[2],aver[i],rank[i]);     fclose(fp1);     fclose(fp2);     return 0; } 供参考～ 谢谢你，感觉自己是真的蠢总犯这种小错误

user: user-1
content: #include <stdio.h> #include <stdlib.h>  struct student {     long num;     char name[10];     float score[3]; }ml[10];  void mr(float aver[],int rank[]) {     int i,j,a;     for(i=0;i<10;i++)     {         a=1;         for(j=0;j<10;j++)         {             if(aver[i]<aver[j])                 a=a+1;         }         rank[i]=a;     } } int main() {     FILE *fp1,*fp2;     int i,rank[10];     float aver[10];     if((fp1=fopen("E:\\student1.txt","r"))==NULL)     {         printf("无法打开文件\n");         exit(0);     }     fp2 = fopen("E:\\student2.txt","w");     if (!fp2) {         printf("无法打开文件\n");         exit(0);     }  #if 0     for(i=0;i<10;i++)         //fscanf(fp1,"%ld %s %f %f %f",ml[i].num,ml[i].name,ml[i].score[0],ml[i].score[1],ml[i].score[2]);         fscanf(fp1,"%ld %s %f %f %f", &ml[i].num,ml[i].name, &ml[i].score[0], &ml[i].score[1], &ml[i].score[2]);     for(i=0;i<10;i++)     {         aver[i]=(ml[i].score[0]+ml[i].score[1]+ml[i].score[2])/3.0;     } #else     for(i=0;i<10;i++) {         //fscanf(fp1,"%ld %s %f %f %f",ml[i].num,ml[i].name,ml[i].score[0],ml[i].score[1],ml[i].score[2]);         fscanf(fp1,"%ld %s %f %f %f", &ml[i].num,ml[i].name, &ml[i].score[0], &ml[i].score[1], &ml[i].score[2]);         aver[i] = (ml[i].score[0]+ml[i].score[1]+ml[i].score[2])/3.0;     } #endif     mr(aver,rank);     for(i=0;i<10;i++)         fprintf(fp2,"%-9ld%-10s%-5.1f%-5.1f%-8.1f%-10.1f%-d\n",ml[i].num,ml[i].name,ml[i].score[0],ml[i].score[1],ml[i].score[2],aver[i],rank[i]);     fclose(fp1);     fclose(fp2);     return 0; } 供参考～