专业的游戏资讯门户网站,爱游戏就上Gmae234!
游戏网 > 问答列表 >

求C语言高手帮忙!已知有n名学生学号、姓名、课程成绩,设计一个菜单程序,完成功能如下:打印姓名,总分

n已知有n名学生学号、姓名、课程成绩设计一个菜单程序,完成功能如下:①打印姓名,总分;打印学号、姓名、成绩、总分、名次。...

   404

404,您请求的文件不存在!

   2019-04-24 11:10:34


采纳答案   main()
{void add1();
void add2();
void add3();
int x;
system("grftabl 936");
textbackground(20);
textcolor(14);
while(1)
{clrscr();
printf("\n\n\n\n");
printf(" *程序菜单*\n");
printf("****************************\n");
printf("* 1、 姓名、学号、总分 *\n");
printf("* 2、学号、姓名、成绩、总分、名次 *\n");
printf("* 3、 退 出 *\n");
printf("***************************|");
printf(" 请选择1---3:");
scanf("%d",&x);
switch(x)
{case 1:clrscr();add1();getch();continue;
case 2:clrscr();add2();getch();continue;
case 3:clrscr();add3();getch();break;}
break;}}
void add1()
{int c[5];int i,t,j,m,v;
int a[5]={106011023,11024,11025,11026,11027};
char n[5][118]={" 张三 "," 李四 "," 王五 "," 杨六 "," 黄七 "};
int b[5][4]={{67,89,91,83},
{54,86,84,71},
{67,94,78,81},
{78,76,90,77},
{96,87,83,81}};
clrscr();
for(v=0;v<5;v++)
printf("\n");
printf(" # 成绩表 #\n");
printf("\n");
printf(" ┌————————┬————————┬———————┐\n");
printf(" │ 学号 │ 姓名 │ 总分 │\n");
for(i=0;i<5;i++)
{printf(" ├————————┼————————┼———————┤\n");
printf(" │ %5d │",a[i]);
for(m=0;m<6;m++)
printf("%c",n[i][m]);
c[i]=b[i][0]+b[i][1]+b[i][2]+b[i][3];
printf("│%-9d",c[i]);
printf("│");
printf("\n");
}
printf(" └————————┴————————┴———————┘\n");
getch();}
void add2()
{int c[5];int i,t,j,m,v;
int a[5]={10501,10502,10503,10504,10505};
char n[5][18]={" 肥 "," 军 "," 小 "," 沈 "," 李 "};
int b[5][4]={{67,89,91,83},
{54,86,84,71},
{67,94,78,81},
{78,76,90,77},
{96,87,83,81}};
clrscr();
for(v=0;v<5;v++)
printf("\n");
printf(" # 成绩表 #\n");
printf("\n");
printf(" |******|******|******|\n");
printf(" | 学号 | 姓名 | 总分 |\n");
for(i=0;i<5;i++)
{printf(" |******|******|******|\n");
printf(" |%6d|",a[i]);
for(m=0;m<6;m++)
printf("%c",n[i][m]);
c[i]=b[i][0]+b[i][1]+b[i][2]+b[i][3];
printf("|%-6d",c[i]);
printf("|");
printf("\n");
}
printf(" |********************|\n");
getch();}
void add3()
{
printf("\n");
getch();}    2019-04-24 11:10:34

 和你要的差不多!如果要帮你改改
#include 
#include 
#include 
#include 
int n;
struct student
{
    char name[100];
    int number;
    float math;
    float english;
    float conputer;
    float chine;
    float sum;
    struct student *node; 
};
int input(struct student *head)
{
  struct student *p1=head->node;
  int i=1;
  printf("全班信息如下: ");
  printf("================================================================================ ");
  while(p1!=NULL)
  {
        printf("第%d名 姓名%s 学号%d  数学%5.2f 英语%5.2f 计算机%5.2f 语文%5.2f 总分%5.2f ",i++,p1->name,p1->number,p1->math,p1->english,p1->conputer,p1->chine,p1->sum);
       p1=p1->node;
       printf(" ");
  }
    printf("================================================================================ ");
return 0;
}

int sort(struct student *head)
{
  struct student *p1,*p2;
  char ch[100];
  int temp,i,j;
  float temp1;
  for(i=1;i  {
      p1=p2=head->node;
      for(j=0;j      {
           p1=p2;
           p2=p2->node;
           if(p1->sumsum)
           {
               strcpy(ch,p1->name);
               strcpy(p1->name,p2->name);
               strcpy(p2->name,ch);
               temp=p1->number;
               p1->number=p2->number;
               p2->number=temp;
               temp1=p1->chine;
               p1->chine=p2->chine;
               p2->chine=temp1;
               temp1=p1->conputer;
               p1->conputer=p2->conputer;
               p2->conputer=temp1;

               temp1=p1->english;
               p1->english=p2->english;
               p2->english=temp1;

               temp1=p1->math;
               p1->math=p2->math;
               p2->math=temp1;
               temp1=p1->sum;
               p1->sum=p2->sum;
               p2->sum=temp1;
           
           }
      
      
      }
  }
  input(head);
return 0;
}
struct student * editor(void)
{
    struct student *head,*p1,*p2;
    int num;
    head=(struct student *)malloc(sizeof(struct student));
    if(head==NULL)
    {
        printf("内存不足分配失败!");
        exit(-1);
    }
    head->node=NULL;
    p2=head;
    printf("请输入学生学号[0退出] ");
    scanf("%d",&num);
    while(num!=0)
    {
        p1=(struct student *)malloc(sizeof(struct student));
        if(p1==NULL)
        {
            printf("内存不足分配失败!");
            exit(-1);
        }
        printf("请输入学生姓名 ");
        scanf("%s",p1->name);
        getchar();
        printf(" ");
        printf("请输入数学成绩 ");
        scanf("%f",&p1->math);
         getchar();
         printf(" ");
         printf("请输入英语成绩 ");
         scanf("%f",&p1->english);
         getchar();
         printf(" ");
         printf("请输入计算机成绩 ");
         scanf("%f",&p1->conputer);
         getchar();
         printf(" ");
         printf("请输入语文成绩 ");
         scanf("%f",&p1->chine);
         getchar();
         printf(" ");
         p1->sum=p1->chine+p1->conputer+p1->english+p1->math;
         p1->number=num;
         p1->node=NULL;
         p2->node=p1;
         p2=p1;
         n++;
         printf("请输入学生学号[0退出] ");
         scanf("%d",&num);
         getchar();
         printf(" ");
         
                 
    }
    sort(head);
    
    return head;
}
int main()
{
    struct student *head;
    head=editor();
    
    return 0;
}   2019-04-24 11:10:34

ask1ask2ask3ask4ask5ask6ask7ask8ask9ask10ask11ask14ask13ask14ask15

游戏推荐更多>