新手自己编的,求高手改正
#include<stdio.h>#include<stdlib.h>
#define N 10
struct
{
int num ;
char name[N];
int waiyu;
int shuxue;
int diannao;
}stu[20]={{20100,"aa",88,92,86},\ /***初始化结构体数组***/
{20101,"bb",58,69,75},\
{20102,"cc",55,73,80},\
{20103,"dd",58,63,57},\
{20104,"ee",78,80,45},\
{20105,"ff",89,69,75},\
{20106,"gg",57,87,65},\
{20107,"hh",88,89,95},\
{20108,"ii",77,46,67},\
{20109,"jj",85,75,68}};
void funct1(); /***函数声明***/
void funct2();
void funct3();
void funct4();
int main()
{
int i;
char choice;
printf(" \n ercorde name \t \t num\t\twaiyu \tshuxue\tdiannao\n");
for(i=0;i<=N-1;i++) /***结构体数组输出***/
printf(" %d\t%-18s%-9d%10d\t%3d\t%6d\n",i,stu[i].name,stu[i].num,stu[i].waiyu,stu[i].shuxue,stu[i].diannao);
printf(" ===the informination of student===\n");
printf(" -------------------------------------------------------------\n");
printf("\n");
printf(" 1.the avarage of the student 3.stdudent's rank\n");
printf("\n");
printf(" 2.the avarage of the class 4.the name who fail\n");
printf("\n");
printf(" 0.exc\n ");
printf("\n");
printf(" -------------------------------------------------------------\n");
printf("choice the number(0-4):\n"); /***显示菜单***/
printf("please choice:");
do
{
choice=getchar();
switch(choice)
{
case'1': funct1(); break; /***由输入确定调出函数***/
case'2': funct2(); break;
case'3': funct3(); break;
case'4': funct4(); break;
case'0': exit(0);
}
}while(choice);
return 0;
}
void funct1()
{
int m,n,temp,i,b[3]={0,0,0},sum[3]={0,0,0};
{
for(i=0;i<N;i++)
{
sum[i]=stu[i].waiyu+stu[i].shuxue+stu[i].diannao; /***由数组sum【】存放每个学生的总成绩***/
b[i]=sum[i]/3.0; /***由数组b【】存放每个学生的平均成绩***/
printf("the %d'sum is %3d the %d'avarage is %3d\n",stu[i].num,sum[i],i,b[i]); /***输出学生的总成绩和平均成绩***/
}
{
for(n=0;n<=N-2;n++) /***比较学生的平均并输出***/
for(i=0;i<N-n-1;i++)
if(b[i]<b[i+1])
{temp=b[i];b[i]=b[i+1];b[i+1]=temp;}
for(i=0;i<=N-1;i++)
printf(" the avarage %d is the rank %d\n",b[i],i+1);
}
}
}
void funct2()
{
int i,b[N]={0,0,0},sum[N]={0,0,0},m1=0,m2=0,m3=0,m4=0,c;
for(i=0;i<N;i++)
{
sum[i]=stu[i].waiyu+stu[i].shuxue+stu[i].diannao;
b[i]=sum[i]/3.0; /***算出每个学生的平均成绩***/
printf(" the %d'avarage is %3d\n",stu[i].num,b[i]);
}
for(i=0;i<N;i++)
{
c=b[i]/10;
switch(c) /***确定每个分数段的人数***/
{
case 1:
case 2:
case 3:
case 4:
case 5: m1=m1+1; break;
case 6:
case 7: m2=m2+1; break;
case 8: m3=m3+1; break;
case 9:
case 10:m4=m4+1; break;
}
}
printf("below 60:%d 60-79:%d 80-89:%d above90:%d",m1,m2,m3,m4); /***输出每个分数段的人数***/
}
void funct3()
{
int i,num;
printf("please the number of the student:");
scanf("%d",&num);
printf("\n ercorde name \t \t num\t\twaiyu \tshuxue\tdiannao\n"); /***输出表头***/
for (i=0;i<N;i++)
{
if (num==stu[i].num) /***检索***/
{
printf ("%d\t%-18s%-9d%10d\t%3d\t%6d\n",i,stu[i].name,stu[i].num,stu[i].waiyu,stu[i].shuxue,stu[i].diannao); /***输出检索结果***/
}
}
}
void funct4()
{
int i;
printf ("the name of waiyu fail:"); /***输出英语成绩***/
for(i=0;i<N;i++)
{
if(stu[i].waiyu<60) /***进行比较***/
printf ( "%s\n",stu[i].name); /***输出成绩不及格人数***/
}
printf ("the name of shuxue fail:");
for(i=0;i<N;i++)
{ /***输出数学成绩***/
if(stu[i].shuxue<60) /***进行比较***/
printf (" %s\n",stu[i].name); /***输出成绩不及格人数***/
}
printf ("the name of diannao fail:");
for(i=0;i<N;i++) /***输出电脑成绩***/
{
if(stu[i].diannao<60) /***进行比较***/
printf ("%s\n",stu[i].name); /***输出成绩不及格人数***/
}
}
自己编的,想在菜单下工作。求高手指点 为什么输入 1 ,不能返回菜单。