line(stu[i].c);
delete(int i,stu[i].num,stu[i].name,stu[i].c1,stu[i].c2,stu[i].c3);
select(int a);
amend(int i,stu[i].c1,stu[i].c2,stu[i].c3);
zong(double x1,double x2,double x3);
ave(zong(double x1,double x2,double x3),m);
#define n 3;
#define m 3;
#include<stdio.h>
main()
{
int a,b,c,d;
struct student
{
int num
char name[10]
double c1
double c2
double c3
double c
}stu[n]
for(i=1;i<=n;i++)
scanf("%d %c %f %f %f\n",&stu[n].num &stu[n].name &stu[n].c1 &stu[n].c2 &stu[n].c3);
printf("请输入学生学号");
scanf("%d\n",&n);
if(n==1||n==2||n==3)
{
printf("%d %c %f %f %f\n",stu[n].num stu[n].name stu[n].c1 stu[n].c2 stu[n].c3);
printf("%f %f\n",zong(stu[n].c1,stu[n].c2,stu[n].c3) ave(zong(stu[n].c1,stu[n].c2,stu[n].c3),m));
printf("%d\n",line(stu[n].c1));
printf("%d\n",line(stu[n].c2));
printf("%d\n",line(stu[n].c3));
printf("%d\n",line(zong(stu[n].c1,stu[n].c2,stu[n].c3));
}
printf("请输入查询的学生学号");
scanf("%d\n",&b);
if(b==1||b==2||b==3)
select(int b);
printf("请输入要删除的学生学号");
scanf("%d\n",&c);
if(c==1||c==2||c==3)
delete(int c,stu[c].num,stu[c].name,stu[c].c1,stu[c].c2,stu[c].c3);
printf("请输入要修改的学生学号,各科的成绩");
scanf("%d %f %f %f\n",&d &c1 &c2 &c3);
if(d==1||d==2||d==3)
amend(int d,double c1,double c2,double c3);
}
zong(double x1,double x2,double x3)
{
double sum;
sum=x1+x2+x3;
return(sum);
}
ave(zong(double x1,double x2,double x3),m)
{
int result;
result=zong(double x1,double x2,double x3);
return(result/m);
}
line(stu[i].c)
{
int i,j,count=0;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
while(stu[i].c>stu[j].c)
count++;
}
return(n-count);
}
delete(int i,stu[i].num,stu[i].name,stu[i].c1,stu[i].c2,stu[i].c3)
{
int k;
if(i<1||i>n)
return 0;
else for(k=i;k<n;k++)
{
stu[k].num=stu[k+1].num;
stu[k].name=stu[k+1].name;
stu[k].c1=stu[k+1].c1;
stu[k].c2=stu[k+1].c2;
stu[k].c3=stu[k+1].c3;
}
}
select(int a)
{
if(a==1)
printf("%d %c %f %f %f\n",stu[a].num stu[a].name stu[a].c1 stu[a].c2 stu[a].c3);
else if(a==2)
printf("%d %c %f %f %f\n",stu[a].num stu[a].name stu[a].c1 stu[a].c2 stu[a].c3);
else
printf("%d %c %f %f %f\n",stu[a].num stu[a].name stu[a].c1 stu[a].c2 stu[a].c3);
}
amend(int i,stu[i].c1,stu[i].c2,stu[i].c3)
{
n=i;
stu[n].c1=stu[i].c1;
stu[n].c2=stu[i].c2;
stu[n].c3=stu[i].c3;
}
希望高手帮忙看看。改一改啊
谢谢。请多多指教啊