求高手看看这段程序,为何编译不了。
#include "stdio.h"struct John
{int num;
char name[20];
double co1,co2,co;
}
main()
{typedef struct John AA;
AA data[100],t;
char k,kk;
int i,j,n,m;
FILE *fp;
printf("输入学生人数:\n");
scanf("%d",&n);
for(i=0;i<n;i+=1)
{printf("输入学生%d信息:\n",i+1);
printf("学号:");
scanf("%d",&data[i].num);
getchar();
printf("姓名:");
gets(data[i].name);
printf("平时成绩:");
scanf("%f",&data[i].co1);
getchar();
printf("考试成绩:");
scanf("%f",&data[i].co2);
getchar();
data[i].co=data[i].co2*(7.0/10.0)+data[i].co1*(3.0/10.0);
}
fp=fopen("myfile.txt","w");
fprintf(fp,"学生信息如下:\n");
fclose(fp);
fp=fopen("myfile.txt","a");
for(i=0;i<n;i+=1)
{fprintf(fp,"学号:");
fprintf(fp,"%d\n",data[i].num);
fprintf(fp,"姓名:");
fprintf(fp,"%s\n",data[i].name);
fprintf(fp,"平时成绩:");
fprintf(fp,"%.2f\n",data[i].co1);
fprintf(fp,"考试成绩:");
fprintf(fp,"%.2f\n",data[i].co2);
fprintf(fp,"总成绩:");
fprintf(fp,"%.2f\n\n",data[i].co);
}
fclose(fp);
for(i=0;i<n-1;i+=1)
for(j=i+1;j<n;j+=1)
if(data[i].co<data[j].co)
{t=data[i];
data[i]=data[j];
data[j]=t;
}
printf("按降序排列后成绩:\n");
for(i=0;i<n;i+=1)
{printf("学号:%d\n",data[i].num);
printf("姓名:%s\n",data[i].name);
printf("平时成绩:%.2f\n",data[i].co1);
printf("考试成绩:%.2f\n",data[i].co2);
printf("总成绩:%.2f\n\n",data[i].co);
}
printf("是否修改学生成绩(Y/N):");
k=getchar();kk=k;
while(k=='Y')
{printf("输入要修改学生的学号:\n");
scanf("%d",&m);
for(i=0;i<n;i+=1)
if(data[i].num==m)
break;
printf("输入1:修改平时成绩\n");
printf("输入2:修改考试成绩\n");
scanf("%d",&m);
printf("输入新的成绩:");
if(m==1)
scanf("%f",&data[i].co1);
else if(m==2)
scanf("%f",&data[i].co2);
else
printf("\n输入错误!!!");
data[i].co=data[i].co1*(3.0/10.0)+
data[i].co2*(7.0/10.0);
getchar();
printf("是否继续修改(Y/N):");
k=getchar();
}
if(kk=='Y')
printf("修改后成绩:\n");
for(i=0;i<n;i+=1)
{printf("学号:%d\n",data[i].num);
printf("姓名:%s\n",data[i].name);
printf("平时成绩:%.2f\n",data[i].co1);
printf("考试成绩:%.2f\n",data[i].co2);
printf("总成绩:%.2f\n\n",data[i].co);
}
}
一个简单的成绩管理系统,为何总是编译不了!C:\Windows\System32\Cpp1.cpp(97) : warning C4508: 'main' : function should return a value; 'void' return type assumed
!!!求高手解答。。。