c编程、、、、、、、学生综合测评系统每个学生的信息为:学号、姓名、性别、家庭住址、联系电话、语文、数学、外语三门单科成绩

1个回答

  • #include

    #include

    typedef struct stu{

    int id;

    char name[40];

    int mark[4];

    float total;

    } STU;

    int id;

    int m1,m2,m3,m4;

    char str[40];

    void main()

    {

    int i,j,N=0;

    FILE *fin, *fout;

    STU tmp;

    STU *s;

    fin = fopen("score.txt","r");

    while (1){

    if ( fscanf(fin,"%*d %*s %*d %*d %*d %*d") ==EOF) break;

    N++;

    }

    fclose(fin);

    s = (STU *) malloc(N * sizeof(STU));

    if (!s) {

    printf("no enough memory for STUn"); exit(0);

    }

    fin = fopen("score.txt","r");

    for (i=0;i