全文预览

c经典例题100

上传者:相惜 |  格式:pdf  |  页数:61 |  大小:4625KB

文档介绍
ing : The document was created with Spire.PDF for .NET.\rfclose(fp);\r\r?100ñ\rEQÆò žÆòE3 óô?dõ ÑÒÓ°MX(ö÷Æòø ùú hóôdõ) \rÎ0B\rbcdõ ûoE?XˆÎ0B?bc?ãç¨ØÓàá“stud”D\r1 .\r??\r2.\r?\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;\rZ*input*/\rfor(i=0;i<5;i+ + )\r{ printf(H\n please input No. %d score:\n",i);\rprintfC'stuNo:'1);\rscanf("%s",stu[ i] .num);\rprintf(nname:H);\rscanf("%sM,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];\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),1 ,fp)!= 1)\rprintf("file write error\n");\rfclose(fp);

收藏

分享

举报
下载此文档