全文预览

100个经典C语言程序2

上传者:hnxzy51 |  格式:pdf  |  页数:135 |  大小:9284KB

文档介绍
\rfclose(fp);\r}\r\r100þ\r??HTÔÿ 0 @ P 3 `p?\r??\r    ( 0@ `p\n)\r\n!"P?#? $%&'\r(\r)*"stud”+,\r1 ./0$12\r2 ./03452\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("stuNo:");\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+l);\rscanf("%d",&stu[i].score [j]);\rsum+=stu [i]. score [j ];\r}\rstu [i].avr=sum/3.0;\r}\rfp=fopen("stud","w");\rfor(i=0;i<5;i++)\rif(fwrite(&stu[i],sizeof(struct student),l,fp)!=l)\rprintf("file write error\n");\rfclose(fp);\r}

收藏

分享

举报
下载此文档