5-6作业

typedef struct student
{
    char name[16];
    int age;
    double math_score;
    double chinese_score;
    double english_score;
    double physics_score;
    double chemistry_score;
    double bio_score;
}student,*student_p;                           
 student_p create(char w,char a,int b,double c,double d,double e,double f,double g,double h)
 {
     student_p p=(student_p)malloc(sizeof(student));
     if(p=NULL)
     {
         printf("空间申请失败");
         return NULL;
     }
     w.name[16]="a";
     w.age=b;
     w.math_score=c;
     w.chinese_score=d;
     w.english_score=e;
     w.physics_score=f;
     w.chemistry_score=g;
     w.bio_score=h;
     return p;
 }student,*student_P;
 int main(int argc, const char *argv[])
 {
     char a[5][10]={"aa","bb","cc","ee","ff"};
     int b[5]={11,22,44,34,55};
     double c,d,e,f,g,h;
     student A,B,C,D,E;
     char w[5]={'A','B','C','D','E'};
     for(int i=0;i<5;i++)
     {
         printf("输入成绩:");
         scanf("%c%lf%lf%lf%lf%lf%lf",&w[i],&c,&d,&e,&f,&g,&h);
         create(w[i],a[i],b[i],c,d,e,f,g,h);
     }
     FILE *fp=fopen("b.txt","w");
     if(fp==NULL)
     {
         printf("文件打开失败");
         return 1;
     }
     for(int i=0;i<5;i++)
     {
         fprintf(fp,"%c %d %lf %lf %lf %lf %lf %lf",                                                                                                                     
                 w[i].name[16],
                 w[i].age,
                 w[i].math_score,
                 w[i].chinese_score,
                 w[i].english_score,
                 w[i].physics_score,
                 w[i].chemistry_score,
                 w[i].bio_score);
     }
     char str[100];
     while(1)
     {
         int ch=0;
         int vv=fscanf(fp,"%c",&str[ch]);
         ch++;
         if(vv=EOF)
             break;
     }
     puts(str);
     fclose(fp);
     return 0;
 }
                                                                                                                                                                         

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值