这是一个学生管理系统:不知道哪有问提???请各位大哥大姐帮帮忙~
#include<stdio.h>
struct student
{
int no; //学号
char name[15]; //姓名
int score[3]; //三门成绩
double avr; //平均成绩
};
struct student stu[50]; //声明一个结构数组变量
struct student input();
void display (struct student stu[],int count);
void sort (struct student stu[],int count);
void insert (struct student stu[],int count);
void del (struct student stu[],int count);
void main()
{
int count;
char ch;
ch='y';
printf("请输入学员的信息: ");
printf("\n");
count=0;
while((ch=='y')||(ch=='Y'))
{
stu[count]=input(); //调用录用信息函数
count++;
printf("\n是否继续?(y or n)");
scanf("%c",&ch);
}
printf("\n排序前的信息: ");
display(stu,count); //调用显示函数
sort(stu,count); //调用排序函数
printf("\n排序后的信息: ");
display(stu,count);
printf("是否要插入新学员(y or n)");
scanf("%c",&ch);
if(ch=='y'||ch=='Y')
{
insert(stu,count); //调用插入信息
count++;
printf("\n插入新学员信息: ");
display(stu,count);
}
printf("\n\n是否要删除学员信息: ");
scanf("%c",&ch);
if(ch=='y'||ch=='Y')
{
del(stu,count); //调删除示信息
count--;
printf("\n删除后的学员信息: ");
display(stu,count);
}
}
struct student input(); //录入信息函数
{
struct student stud;
int sum;
printf("\n学员:");
scanf("%d",stud.no);
printf("\n姓名:");
scanf("%d",stud.name);
printf("\n三门成绩:");
sum=0;
printf("\n");
for(j=0;j<3;j++)
{
printf("成绩%d: ",j+1);
scanf("%d",&stud.score)
sum+=stud.score[j];
}
stud.avr=sum/3;
return stud;
}
void dispaly(struct student stu[],int count)//显示信息
{
int i;
printf("\n学号\t姓名\t\t平均成绩");
printf("\n");
for(i=0;i<count;i++)
{
printf("%-3d",stu[i].no);
printf("\t%-15s",stu[i].name);
printf("\t%-10.1f",stu[i].avr);
printf("\n");
}
}
void sore(struct student stu[],int count)//排序函数
{
struct student t;
int i,j;
for(i=0;i<count;i++)
{
for(j=0;j<count-i-1;j++)//比较
{
if(stu[j].avr<stu[j+i].avr)
{
t=stu[j];
stu[j]=stu[j+1];
stu[j+1]=t;
}
}
}
}
void insert ( struct student stu[],int count) //插入函数
{
/*插入一个学员的信息,要求插入后的学员信息依然有序*/
int i,j;
struct student temp;
printf("\n请输入要插入的学员新系");
temp=input();
for(i=0;i<count;i++)
{
if(stu[i].avr<temp.avr)
break;
}
for(j=count;j>=i;j--)
{
stu[j+1]=stu[j];
}
stu[i]=temp;
}
void del(struct student stu[],int count) //删除函数
{
int dno;
int i;
int j;
printf("请输入要删除的学员:");
scanf("%d",&dno);
for(i=0;i<count;i++)
{
if(stu[i].no==dno)
break;
}
for(j=i;j<count-1;j++)
{
stu[j]=stu[j+1];
}
}
Compiling...
gfgd.c
D:\MSDev98\MyProjects\tyt\gfgd.c(56) : error C2449: found '{' at file scope (missing function header?)
D:\MSDev98\MyProjects\tyt\gfgd.c(74) : error C2059: syntax error : '}'
Error executing cl.exe. 2处错误
还是没有正确答案
可以运行不过是一堆乱吗