全文预览

100个经典c程序

上传者:科技星球 |  格式:pdf  |  页数:61 |  大小:6926KB

文档介绍
]);\r)\rfclose(fp);\r)\r?78100Ö\r@A: ?¢×pu¢× 3 ØÙ&Úp°±²³‰G(ÛÜ¢×\rÝpÞßp*ØÙ&Ú)p¬­x\r$%&Úpà2 G\¬­x$%?GÆʁ¹²ÃÄ“stud”\r1 .78?9:\r2 .78;<=:\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(á0;iv5;i+ + )\r{ printf("\n please input No. %d score:\n",i);\rprintf("stuN");\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("%d",&stu[i].score[j]);\rsum+ = stu[i].score[j];.\rstu[i].avr=sum/3.0;\r)\rfp= fopen("stud","w");\rfor(i=0;i<5;i+ + )\rif(fwrite(&stu[i],sizeof(struct student),1 ,fp)!= 1)\rprintf("file write error\n");\rfclose(fp);

收藏

分享

举报
下载此文档