|  | 
 
 
 楼主|
发表于 2020-6-24 10:47:45
|
显示全部楼层 
| 经过我的不懈努力,终于还是写出来了
 复制代码#include <stdlib.h>
#include <stdio.h>
typedef struct student
{
    char name[20];
    int ma;
    int com;
    int en;
    int score;
} stu;
int i=0,j,n=0;
stu str[1000];
int main(void)
{
    FILE *fp=fopen("D:/info.txt","r");
    printf("所有学生信息如下:\n");
    while(fscanf(fp,"%s",str[i].name)!=EOF){
        fscanf(fp,"%d%d%d",&str[i].ma,&str[i].com,&str[i].en);
        printf("name:%s\t       math:%d      computer:%d      english:%d\n",str[i].name,str[i].ma,str[i].com,str[i].en);
        i++;
    }
    printf("以下同学没通过考试\n");
    for(j=0;j<i;j++){
        str[j].score=str[j].ma+str[j].com+str[j].en;
        if(str[j].score<210 || str[j].ma<60 || str[j].com<60 || str[j].en<60)
        {
            printf("%s\n",str[j].name);
            n=n+1;
        }
    }
    printf("没有通过考试的人数:%d\n",n);
    fclose(fp);
    return 0;
}
 
 | 
 |