标题:能不能帮我看一下,这个哪里有出错吗?
取消只看楼主
hqfjpt
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2011-6-23
结帖率:75%
已结贴  问题点数:15 回复次数:4 
能不能帮我看一下,这个哪里有出错吗?

#include "stdio.h"
#include "conio.h"
#include "stdlib.h"
#include "string.h"
#define N  3

struct student
 { long int number;
   char name[10];
   float s[5],sum,ave;
 }temp,stu[N]= {{10010,"lin",1,1,1,1,1},
                {10011,"huang",0,0,0,0,0},
                {10012,"cheng",2,2,2,2,2}
               };
void print(struct student stu[ ],int i)
 { int  j;
   printf("||number||    name||\n");
   printf("||%ld ||%8s||\n",stu[i].number,stu[i].name);
   for (j=0;j<5;j++)
   printf("score%d=:%8.1f\n",j+1,stu[i].s[j]);
   printf("\n");

  }
void Input(struct student stu[ ],int i)
 { int  j;
   float k;
     printf("Please input the student's number=:");
     scanf("%ld",&stu[i].number);
     printf("Please input the student's name=:");
     scanf("%s",&stu[i].name);
     for (j=0;j<5;j++)
        {printf("Please input the student's score%d=:",j+1);
         scanf("%f",&k);
         stu[i].s[j]=k;
        }
      print(stu,i);
  }


 void Add(struct student stu[ ],int i)
 { int  j;
   float k;
     printf("Please input the student's number=:");
     scanf("%ld",&stu[i+N-1].number);
     printf("Please input the student's name=:");
     scanf("%s",&stu[i+N-1].name);
     for (j=0;j<5;j++)
        {printf("Please input the student's score%d=:",j+1);
         scanf("%f",&k);
         stu[i+N-1].s[j]=k;
        }
      for(j=0;j<N+1;j++)
      {print(stu,j);}
  }

 void Change(struct student stu[ ],int i)
 {  int j,k;
   long int m;
   float p;
   printf("Please input the student's number:\n");
   scanf("%ld",&m);
   for(j=0;j<N;j++)
   {  if (stu[j].number==m)
      {  k=j;
       print(stu,j);
       printf("\n");
       }
   }
     do
    {printf("\t\t\t***  1.Change     the  student's score1     ***\t\t\t\n");
     printf("\t\t\t***  2.Change     the  student's score2     ***\t\t\t\n");
     printf("\t\t\t***  3.Change     the  student's score3     ***\t\t\t\n");
     printf("\t\t\t***  4.Change     the  student's score4     ***\t\t\t\n");
     printf("\t\t\t***  5.Change     the  student's score5     ***\t\t\t\n");
     printf("Please input i=:\n");
     scanf("%d",&i);
     switch (i)
      { case 1:printf("Please input the student's score1:\n");
              scanf("%f",&p);
              stu[k].s[0]=p;
              print(stu,k);break;
        case 2:printf("Please input the student's score2:\n");
              scanf("%f",&p);
              stu[k].s[1]=p;
              print(stu,k);break;
        case 3:printf("Please input the student's score3:\n");
              scanf("%f",&p);
              stu[k].s[2]=p;
           print(stu,k);break;
        case 4:printf("Please input the student's score4:\n");
              scanf("%f",&p);
              stu[k].s[3]=p;
             print(stu,k);break;
        case 5:printf("Please input the student's score5:\n");
              scanf("%f",&p);
              stu[k].s[4]=p;
              print(stu,k);break;
      }}while (i!=0);
      printf("please wait input any key continue");
      getch();
    }
 void Delete (struct student stu[ ],int i)
 { long int m;
   printf("Please input the student's number=:\n");
   scanf("%ld",&m);
   for(i=0;i<N;i++)
   {  if (stu[i].number==m)
      {  stu[i]=stu[i+1];
       }
    }
    for(i=0;i<N-1;i++)
    { print(stu,i);
     }
 }
 void Inquire(struct student stu[ ],int i)
 { long int m;
   printf("Please input the student's number=:\n");
   scanf("%ld",&m);
   for(i=0;i<N;i++)
   {  if (stu[i].number==m)
      { print(stu,i);
       }
   }
   printf("please wait input any key continue");
   getch();
}
  void Sort(struct student stu[ ],int i)
  {int j;
   float a;
    for (i=0;i<N;i++)
     {for (j=0;j<5;j++)
       {a=0;
        a+=stu[i].s[j];
        stu[i].sum=a;
        print(stu,i);
        printf("%8.1f\n",stu[i].sum);
        }
      }
     for (i=0;i<N;i++)
      {for (j=0;j<N+1;j++)
        {if (stu[i].sum>stu[j].sum)
           {temp=stu[i];
            stu[i]=stu[j];
            stu[j]=temp;
            }
        }
        print(stu,i);
        printf("%8.1f\n",stu[i].sum);
       }
       printf("please wait input any key continue");
       getch();
   }
 void Statistics(struct student stu[ ],int i)
 {int j,m=0,b=0;
   for (i=0;i<3;i++)
     for (j=0;j<5;j++)
       {if (stu[i].s[j]<60)
          { m++;
            printf("||number||name||\n");
            printf("||%ld||%s||\n",stu[i].number,stu[i].name);
           }
       }
       printf("the student don't pass exam have:%d\n",m);
       for (i=0;i<3;i++)
           for (j=0;j<5;j++)
           {  if (stu[i].s[j]>80)
               {b++;
                printf("||number||name||\n");
                printf("||%ld||%s||\n",stu[i].number,stu[i].name);
               }
           }
           printf("the student  pass exam have:%d\n",b);
}



main()
 {  int select,i=0;
    float k;
    do
    {
    printf("\t\t\t***--------------------------------------------***\t\t\t\n");
    printf("\t\t\t***                                            ***\t\t\t\n");
    printf("\t\t\t***  Welcome to The Student's Mangement System ***\t\t\t\n");
    printf("\t\t\t***                                            ***\t\t\t\n");
    printf("\t\t\t***--------------------------------------------***\t\t\t\n");
    printf("\t\t\t***  1.Input      the  student's date          ***\t\t\t\n");
    printf("\t\t\t***  2.Add        the  student's date          ***\t\t\t\n");
    printf("\t\t\t***  3.Delete     the  student's date          ***\t\t\t\n");
    printf("\t\t\t***  4.Change     the  student's date          ***\t\t\t\n");
    printf("\t\t\t***  5.Inquire    the  student's date          ***\t\t\t\n");
    printf("\t\t\t***  6.Sort       the  student's date          ***\t\t\t\n");
    printf("\t\t\t***  7.Statistics the  student's date          ***\t\t\t\n");
    printf("\t\t\t***  0.Escape     the  student's system        ***\t\t\t\n");
    printf("Please input select=:\n");
    scanf("%d",&select);
      switch (select)
      {  case 1:Input(stu,i);break;
         case 2:Add(stu,i);break;
         case 3:Delete(stu,i);break;
         case 4:Change(stu,i);break;
         case 5:Inquire(stu,i);break;
         case 6:Sort(stu,i);break;
         case 7:Statistics(stu,i);break;
         default:printf("It's wrong");break;
       }
    }while(select!=0);
 }
搜索更多相关主题的帖子: 10010 long include number huang 
2011-06-26 01:43
hqfjpt
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2011-6-23
得分:0 
是菜单的do while吗?我试了一下,好像还是不行呀!
2011-06-26 14:44
hqfjpt
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2011-6-23
得分:0 
每次输入数据后,都直接没了,没有再输出数据,我是想输入后输出一个类似表格的东西
2011-06-26 14:46
hqfjpt
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2011-6-23
得分:0 
可是为什么我运行case1时候,总是输入后就跳出呢?没有输出数据
2011-06-26 15:31
hqfjpt
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2011-6-23
得分:0 
回复 7楼 zjl01223
可是为什么我运行case1时候,总是输入后就跳出呢?没有输出数据
2011-06-26 15:54



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-344007-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.070953 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved