当前位置:编程学习 > C/C++ >>

(C语言)有四个警告,不能出运行结果,请帮忙看下,

#include<stdio.h> #include<string.h> struct student { char no[10],name[10],易做图[4]; float t[4],ave; } main() { FILE *fp1; int i,k,j; float sum; struct student z; struct student b[3]; struct student w[3]; struct student s[3]={{"100101","阎 旭","男",88,92,78,86},{"100102","王珊珊","女",78,95,76,87},{"100103","姚彦兆","男",82,89,86,90}}; if((fp1=fopen("d:\\student.dat","wb"))==NULL) { printf("file can not open!\n"); return; } for(i=0;i<3;i++) { fwrite(&s[i],sizeof(s),1,fp1); } fclose(fp1); if((fp1=fopen("d:\\student.dat","rb"))==NULL) { printf("file can not open!\n"); return; } for(i=0;i<3;i++) { fread(&b[i],sizeof(s),1,fp1); } fclose(fp1); printf("\n"); for(i=0;i<3;i++) printf("%s%s%s%.2f%.2f%.2f%.2f",b[i].no,b[i].name,b[i].易做图,b[i].t[0],b[i].t[1],b[i].t[2],b[i].t[3]); for(i=0;i<3;i++) { sum=0; for(j=0;j<4;j++) { sum=sum+s[i].t[j]; } s[i].ave=sum/4; } for(i=1;i<3;i++) { k=i; for(j=k+1;j<3;j++) { if(s[j].ave>s[k].ave) k=j; } if(k!=j) { z=s[i]; s[i]=s[k]; s[k]=z; } } if((fp1=fopen("d:\\stusort.dat","wb"))==NULL) { printf("file can not open!\n"); return; } for(i=0;i<3;i++) { fwrite(&s[i],sizeof(s),1,fp1); } fclose(fp1); if((fp1=fopen("d:\\stusort.dat","rb"))==NULL) { printf("file can not open!\n"); return; } for(i=0;i<3;i++) { fread(&w[i],sizeof(s),1,fp1); } fclose(fp1); printf("\n"); for(i=0;i<3;i++) printf("%s%s%s%.2f%.2f%.2f%.2f%.2f",w[i].no,w[i].name,w[i].易做图,w[i].t[0],w[i].t[1],w[i].t[2],w[i].t[3],w[i].ave); }
追问:warning C4033: 'main' must return a value
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,