user-0 提问: 求助，我是初学者，帮忙查程序错误

回复:
user: user-1
content: #include<stdio.h> #include<stdlib.h> #define N 4 struct student {     //char xuehao;     //char name;     char xuehao[16];     char name[16];     int score1;     int score2;     int score3;     int score4;     double s; } str[30];  double func(int a,int b,int c,int d);  int main() {     struct student temp;     int i, k = 0;     double jidian[30];     FILE* fp;     if ((fp = fopen("D:\\ data.txt","r"))== NULL)     {         printf("无法打开文件\n");         getchar();         exit(1);     }     for (i = 0; i <30; i++)     {         //fscanf(fp, "%s%s%d%d%d%d", &str[i].xuehao, &str[i].name, &str[i].score1, &str[i].score2, &str[i].score3, &str[i].score4);         fscanf(fp, "%s%s%d%d%d%d", str[i].xuehao, str[i].name, &str[i].score1, &str[i].score2, &str[i].score3, &str[i].score4);         jidian[i]=func(str[i].score1,str[i].score2,str[i].score3,str[i].score4);         if (jidian[i]>5.99 && str[i].score1 >= 60 && str[i].score2>=60 && str[i].score3>= 60 && str[i].score4>=60)         {             str[i].s= (jidian[i] * 5 + 50) * 0.75 + (N * 0.25);             k++;         }     }     for(i=0;i<30;i++)     {   //这是做啥？按照每个成绩交换一下，那么如果是排序你是以那个为准呢？         if(str[i].score1<str[i+1].score1)         {             temp=str[i] ;             str[i]=str[i+1] ;             str[i+1]=temp;         }         if(str[i].score2<str[i+1].score2)         {             temp=str[i] ;             str[i]=str[i+1] ;             str[i+1] =temp;         }         if(str[i].score3<str[i+1].score3)         {             temp=str[i] ;             str[i]=str[i+1] ;             str[i+1]=temp;         }         if(str[i].score4<str[i+1].score4)         {             temp=str[i] ;             str[i]=str[i+1] ;             str[i+1]=temp;         }     }     printf("满足奖学金要求的名单\n");     printf("学号        姓名\n");     for (i = 0; i < k; i++)     {         printf("%s        %s    \n", str[i].xuehao, str[i].name);     }     printf("一等奖学金：\n");     printf("学号        姓名\n");     for (i = 0; i < 1; i++)     {         printf("%s        %s    \n", str[i].xuehao, str[i].name);     }     printf("二等奖学金：\n");     printf("学号        姓名\n");     for (i = 1; i < 4; i++)     {         printf("%s        %s    \n", str[i].xuehao, str[i].name);     }     printf("三等奖学金：\n");     printf("学号        姓名\n");     for (i = 4; i < k; i++)     {         printf("%s        %s    \n", str[i].xuehao, str[i].name);     }     fclose(fp);     getchar();     return 0; } double func(int A,int B,int C,int D) {     double j1,j2,j3,j4,jz;     if(A<60)     {         j1=0;     }     //else if(A=60)     else if(A==60)     {         j1=2;     }     else     {         j1=(A-60)*0.2+2;     }     if(B<60)     {         j2=0;     }     //else if(B=60)     else if(B==60)     {         j2=2;     }     else     {         j2=(B-60)*0.2+2;     }     if(C<60)     {         j3=0;     }     //else if(C=60)     else if(C==60)     {         j3=2;     }     else     {         j3=(C-60)*0.2+2;     }     if(D<60)     {         j4=0;     }     //else if(D=60)     else if(D==60)     {         j4=2;     }     else     {         j4=(D-60)*0.2+2;     }     jz=(j1*5+j2*6+j3*4+j4*3)/18;     return jz;   } 供参考～  没有测试，看到不对的地方就改了～