全文预览

C语言经典例题100 (二)

上传者:梦溪 |  格式:pdf  |  页数:60 |  大小:5121KB

文档介绍
;\r)\r0@P100ƒ\r`p?.;´â‡;´â3 ãä?FåÁÂÃ=š)Y6æçè´âéêëJãäFåì.\r½¾\rDEFåíP?Y6n½¾?DEYÔؒÈÃÑÒ“stud”\r1 .@P?\r2  @P !"?\r# include "stdio.h"\rstruct student\r{ char num[6];\rchar name[8];\rint score[3];\rfloat avr;\r} stu[5];\rmain()\r{ int i,j,sum;\rFILE*fp;\r"input*/\rfor(i=0;i<5;i+ + )\r{ printf("\n please input No. %d score:\n",i);\rprintf(HstuNo:");\rscanf("%s'*,stu[i] .num);\rprintf("name:");\rscanf("%s",stu[i] .name);\rsum = 0;\rfor(j=0;j<3;j + + )\r{ printf("score %d.",j+1);\rscanf(H%d",&stu[i].score[j]);\rsum + = stu[i] .score[j];\r)\rstu[i] .avr= sum/3.0;\r)\rfp=fopen("studM,"w");\rfor(i=0;i<5;i+ + )\rif(fwrite(&stu[i],sizeof(struct student),1 ,fp)!= 1)\rprintf("file write error\n");\rfclose(fp);

收藏

分享

举报
下载此文档