全文预览

c语言经典100例9

上传者:qnrdwb |  格式:pdf  |  页数:74 |  大小:5453KB

文档介绍
‡ˆ‰(Š‹~ŒTŽT\r‚ ƒ „ )T‘ \r’“ƒ„T”•aˆ‰d‘ ’“ˆg–`p??/stud/?\r1 . !\r2 .$%&!\r#include “stdio. h/\r#includeTzconio. h/\rstruct student\r(\rchar num[6];\rchar name[8];\rint score[3];\rfloat avr;\r}stu[5];\rmain()\r(\rint i, j, sum;\rFILE *fp;\r/*input*/\rfor(i=0;i<5;i++)\r(\rprintf (z/\n please input No. %d score:\nzT, i);\rprintf("stuNo:/)J\rscanf (/%s/Tstu[i]. num);\rprintf("name:/)J\rscanf stu[i]. name);\rsum=0;\rfor(j=0;j<3;j++)\r(\rprintf ("score %d. /, j+1);\rscanf &stu[i]. score[j]);\rsum+=stu[i]. score[j];\r).\rstu[i]. avr=sum/3. 0;\r}\rfp fopen("stud", "w/)J\rfor(i=0;i<5;i++)\rif(fwrite(&stu[i], sizeof(struct student), 1, fp) !=1)\rprintf (''file write error\n/z);\rfclose(fp);\rgetchO ;

收藏

分享

举报
下载此文档