下面这两个问题怎么解决 看不懂
#include"stdio.h"#include"string.h"
/*学生个人信息*/
{
struct student
{
char id[10];
char name[20];
char grade[20];
char pro[40];/*Professional"专业"*/
float mark1;
float mark2;
float mark3;
float average;/*Average"平均"*/
float all_number;
}students[100];
int num=0;
/*求平均值*/
float ave(struct student stu)
{
return(stu.mark1+stu.mark2+stu.mark3)/3;
}
/*求总成绩*/
float all( struct student stu)
{
return(stu.mark1+stu.mark2+stu.mark3);
}
/*通过学号返回数组下标(查找学生)*/
int student_search(char id[])
{
int i;
for (i=0;i<num;i++)
{
if (strcmp(students[i].id,id)==0)
{
return i;
}
}
return -1;
}
/*显示学生记录*/
void student_playsingle(int index)
{
printf("%10s %10s %10s %10s %10s %8s %8s %8s %10s\n",
"学号","姓名","年级","专业","成绩","成绩","成绩","平均成绩","总成绩");
printf("-------------------------------------------------------------\n");
printf("%10s %10s %10s %10s %8.2f %8.2f %8.2f %10.2f %10.2f\n",
students[index].id,
students[index].name,
students[index].grade,
students[index].pro,
students[index].mark1,
students[index].mark2,
students[index].mark3,
students[index].average,
students[index].all_number);
}
/*插入学生信息*/
void student_insert()
{
while(1)
{
printf("请输入学号:");
scanf("%s",&students[num].id);
getchar();
printf("请输入姓名:");
scanf("%s",&students[num].name);
getchar();
printf("请输入年级");
scanf("%s",&students[num].grade);
getchar();
printf("请输入专业");
scanf("%s",&students[num].pro);
getchar();
printf("请输入成绩:");
scanf("%f",&students[num].mark1);
getchar();
printf("请输入成绩:");
scanf("%f",&students[num].mark2);
getchar();
printf("请输入成绩:");
scanf("%f",&students[num].mark3);
getchar();
students[num].average=ave(students[num]);
students[num].all_number=all(students[num]);
num++;
printf("是否继续?(y/n)");
if (getchar()=='n')
{
break;
}
}
}
/*修改学生信息*/
void student_modify()
{
while(1)
{
char id[20];
int index;
printf("请输入要修改的学生的学号:");
scanf("%s",&id);
index=student_search(id);
if (index==-1)
{
printf("学生不存在!\n");
}
else
{
printf("你要修改的学生信息为:\n");
student_playsingle(index);
printf("-- 请输入新值--\n");
printf("请输入学号:");
scanf("%s",&students[index].id);
getchar();
printf("请输入姓名:");
scanf("%s",&students[index].name);
getchar();
printf("请输入年级:");
scanf("%s",&students[index].grade);
getchar();
printf("请输入专业:");
scanf("%s",&students[index].pro);
getchar();
printf("请输入成绩1:");
scanf("%f",&students[index].mark1);
getchar();
printf("请输入成绩2:");
scanf("%f",&students[index].mark2);
getchar();
printf("请输入成绩3:");
scanf("%f",&students[index].mark3);
getchar();
students[index].average=ave(students[index]);
students[index].all_number=all(students[index]);
}
printf("是否继续?(y/n)");
if (getchar()=='n')
{
break;
}
}
}
/*删除学生信息*/
void student_delete()
{
int i;
while(1)
{
char id[20];
int index;
printf("请输入要删除的学生的学号:");
scanf("%s",&id);
getchar();
index=student_search(id);
if (index==-1)
{
printf("学生不存在!\n");
}
else
{
printf("你要删除的学生信息为:\n");
student_playsingle(index);
printf("是否真的要删除?(y/n)");
if (getchar()=='y')
{
for (i=index;i<num-1;i++)
{
students[i]=students[i+1];
}
num--;
}
getchar();
}
printf("是否继续?(y/n)");
if (getchar()=='n')
{
break;
}
}
}
/*按平均值排序*/
void student_sort()
{
int i,j;
struct student tmp;
for (i=0;i<num;i++)
{
for (j=1;j<num-i;j++)
{
if (students[j-1].average<students[j].average)
{
tmp=students[j-1];
students[j-1]=students[j];
students[j]=tmp;
}
}
}
}
/*主程序*/
main()
{
int choice;
while(1)
{
/*主菜单*/
printf("\n------ 学生成绩管理系统------\n");
printf("1. 增加学生记录\n");
printf("2. 修改学生记录\n");
printf("3. 删除学生记录\n");
printf("4. 按平均成绩排序\n");
printf("5. 退出\n");
printf("请选择(1-6):");
scanf("%d",&choice);getchar();
/*学生课程成绩管理
12计算机科学与技术2*/
#include"stdio.h"
#include"string.h"
/*学生个人信息*/
struct student{
char id[10];
char name[20];
char grade[20];
char pro[40];/*Professional"专业"*/
float mark1;
float mark2;
float mark3;
float average;/*Average"平均"*/
float all_number;
}students[100];
int num=0;
/*求平均值*/
float ave(struct student stu)
{
return(stu.mark1+stu.mark2+stu.mark3)/3;
}
/*求总成绩*/
float all( struct student stu)
{
return(stu.mark1+stu.mark2+stu.mark3);
}
/*通过学号返回数组下标(查找学生)*/
int student_search(char id[])
{
int i;
for (i=0;i<num;i++)
{
if (strcmp(students[i].id,id)==0)
{
return i;
}
}
return -1;
}
/*显示学生记录*/
void student_playsingle(int index)
{
printf("%10s %10s %10s %10s %10s %8s %8s %8s %10s\n",
"学号","姓名","年级","专业","成绩","成绩","成绩","平均成绩","总成绩");
printf("-------------------------------------------------------------\n");
printf("%10s %10s %10s %10s %8.2f %8.2f %8.2f %10.2f %10.2f\n",
students[index].id,
students[index].name,
students[index].grade,
students[index].pro,
students[index].mark1,
students[index].mark2,
students[index].mark3,
students[index].average,
students[index].all_number);
}
/*插入学生信息*/
void student_insert()
{
while(1)
{
printf("请输入学号:");
scanf("%s",&students[num].id);
getchar();
printf("请输入姓名:");
scanf("%s",&students[num].name);
getchar();
printf("请输入年级");
scanf("%s",&students[num].grade);
getchar();
printf("请输入专业");
scanf("%s",&students[num].pro);
getchar();
printf("请输入成绩:");
scanf("%f",&students[num].mark1);
getchar();
printf("请输入成绩:");
scanf("%f",&students[num].mark2);
getchar();
printf("请输入成绩:");
scanf("%f",&students[num].mark3);
getchar();
students[num].average=ave(students[num]);
students[num].all_number=all(students[num]);
num++;
printf("是否继续?(y/n)");
if (getchar()=='n')
{
break;
}
}
}
/*修改学生信息*/
void student_modify()
{
while(1)
{
char id[20];
int index;
printf("请输入要修改的学生的学号:");
scanf("%s",&id);
index=student_search(id);
if (index==-1)
{
printf("学生不存在!\n");
}
else
{
printf("你要修改的学生信息为:\n");
student_playsingle(index);
printf("-- 请输入新值--\n");
printf("请输入学号:");
scanf("%s",&students[index].id);
getchar();
printf("请输入姓名:");
scanf("%s",&students[index].name);
getchar();
printf("请输入年级:");
scanf("%s",&students[index].grade);
getchar();
printf("请输入专业:");
scanf("%s",&students[index].pro);
getchar();
printf("请输入成绩1:");
scanf("%f",&students[index].mark1);
getchar();
printf("请输入成绩2:");
scanf("%f",&students[index].mark2);
getchar();
printf("请输入成绩3:");
scanf("%f",&students[index].mark3);
getchar();
students[index].average=ave(students[index]);
students[index].all_number=all(students[index]);
}
printf("是否继续?(y/n)");
if (getchar()=='n')
{
break;
}
}
}
/*删除学生信息*/
void student_delete()
{
int i;
while(1)
{
char id[20];
int index;
printf("请输入要删除的学生的学号:");
scanf("%s",&id);
getchar();
index=student_search(id);
if (index==-1)
{
printf("学生不存在!\n");
}
else
{
printf("你要删除的学生信息为:\n");
student_playsingle(index);
printf("是否真的要删除?(y/n)");
if (getchar()=='y')
{
for (i=index;i<num-1;i++)
{
students[i]=students[i+1];
}
num--;
}
getchar();
}
printf("是否继续?(y/n)");
if (getchar()=='n')
{
break;
}
}
}
/*按平均值排序*/
void student_sort()
{
int i,j;
struct student tmp;
for (i=0;i<num;i++)
{
for (j=1;j<num-i;j++)
{
if (students[j-1].average<students[j].average)
{
tmp=students[j-1];
students[j-1]=students[j];
students[j]=tmp;
}
}
}
}
/*主程序*/
void main()
{
int choice;
while(1)
{
/*主菜单*/
printf("\n------ 学生成绩管理系统------\n");
printf("1. 增加学生记录\n");
printf("2. 修改学生记录\n");
printf("3. 删除学生记录\n");
printf("4. 按平均成绩排序\n");
printf("5. 退出\n");
printf("请选择(1-5):");
scanf("%d",&choice);getchar();
switch(choice)
{
case 1:student_insert();break;
case 2:student_modify();break;
case 3:student_delete();break;
case 4:student_sort();break;
case 5:break;
}
}
}
下面这两个问题怎么解决 看不懂 求解
F:\课程设计\程序\5.0.cpp(6) : error C2447: missing function header (old-style formal list?)
F: \课程设计\程序\5.0.cpp(448) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.
5.0.exe - 1 error(s), 0 warning(s)