Jack's Blog

流淌的心,怎能阻拦,吹来的风,又怎能阻挡。

学生管理系统V1.0

Jacob posted @ Apr 22, 2017 11:48:46 PM in 未分类 with tags C语言 小白进阶 哈工大 小白进阶,sse 学生管理系统 V1.0 实验题 , 855 阅读

Q3134.(10分)第8章实验1:学生成绩管理系统V1.0
某班有最多不超过30人(具体人数由键盘输入)参加某门课程的考试,用一维数组作函数参数编程实现如下学生成绩管理:
(1)录入每个学生的学号和考试成绩;
(2)计算课程的总分和平均分;
(3)按成绩由高到低排出名次表;
(4)按学号由小到大排出成绩表;
(5)按学号查询学生排名及其考试成绩;
(6)按优秀(90~100)、良好(80~89)、中等(70~79)、及格(60~69)、不及格(0~59)5个类别,统计每个类别的人数以及所占的百分比;
(7)输出每个学生的学号、考试成绩。

程序运行结果示例:
Input student number(n<30):
6↙
Management for Students' scores
1.Input record
2.Caculate total and average score of course
3.Sort in descending order by score
4.Sort in ascending order by number
5.Search by number
6.Statistic analysis
7.List record
0.Exit
Please Input your choice:
1↙
Input student's ID, name and score:
11003001 87↙
11003005 98↙
11003003 75↙
11003002 48↙
11003004 65↙
11003006 100↙
Management for Students' scores
1.Input record
2.Caculate total and average score of course
3.Sort in descending order by score
4.Sort in ascending order by number
5.Search by number
6.Statistic analysis
7.List record
0.Exit
Please Input your choice:
2↙
sum=473,aver=78.83
Management for Students' scores
1.Input record
2.Caculate total and average score of course
3.Sort in descending order by score
4.Sort in ascending order by number
5.Search by number
6.Statistic analysis
7.List record
0.Exit
Please Input your choice:
3↙
Sort in descending order by score:
11003006 100
11003005 98
11003001 87
11003003 75
11003004 65
11003002 48
Management for Students' scores
1.Input record
2.Caculate total and average score of course
3.Sort in descending order by score
4.Sort in ascending order by number
5.Search by number
6.Statistic analysis
7.List record
0.Exit
Please Input your choice:
4↙
Sort in ascending order by number:
11003001 87
11003002 48
11003003 75
11003004 65
11003005 98
11003006 100
Management for Students' scores
1.Input record
2.Caculate total and average score of course
3.Sort in descending order by score
4.Sort in ascending order by number
5.Search by number
6.Statistic analysis
7.List record
0.Exit
Please Input your choice:
5↙
Input the number you want to search:
11003004
11003004 65
Management for Students' scores
1.Input record
2.Caculate total and average score of course
3.Sort in descending order by score
4.Sort in ascending order by number
5.Search by number
6.Statistic analysis
7.List record
0.Exit
Please Input your choice:
6↙
<60 1 16.67%
60-69 1 16.67%
70-79 1 16.67%
80-89 1 16.67%
90-99 1 16.67%
100 1 16.67%
Management for Students' scores
1.Input record
2.Caculate total and average score of course
3.Sort in descending order by score
4.Sort in ascending order by number
5.Search by number
6.Statistic analysis
7.List record
0.Exit
Please Input your choice:
7↙
11003001 87
11003002 48
11003003 75
11003004 65
11003005 98
11003006 100
Management for Students' scores
1.Input record
2.Caculate total and average score of course
3.Sort in descending order by score
4.Sort in ascending order by number
5.Search by number
6.Statistic analysis
7.List record
0.Exit
Please Input your choice:
8↙
Input error!
Management for Students' scores
1.Input record
2.Caculate total and average score of course
3.Sort in descending order by score
4.Sort in ascending order by number
5.Search by number
6.Statistic analysis
7.List record
0.Exit
Please Input your choice:
0↙
End of program!

输入格式:
( 1 )录入学生的人数:
                 **输入数据格式:"%d"
                 **提示信息:"Input student number(n<30):\n"
( 2 )录入每个学生的学号和考试成绩:
               **输入数据格式:"%ld%f"
               **提示信息:"Input student's ID, name and score:\n"
输出格式:
菜单项的输出显示:
Management for Students' scores
1.Input record
2.Caculate total and average score of course
3.Sort in descending order by score
4.Sort in ascending order by number
5.Search by number
6.Statistic analysis
7.List record
0.Exit
Please Input your choice:
计算课程的总分和平均分:
              **输出总分与平均分格式:"sum=%.0f,aver=%.2f\n"
按成绩由高到低排出名次表:
              **输出格式:"%ld\t%.0f\n"
              **提示信息:"Sort in descending order by score:\n"
按学号由小到大排出成绩表:
              **输出格式:"%ld\t%.0f\n"
              **提示信息:"Sort in ascending order by number:\n"
按学号查询学生排名及其考试成绩:
               **如果未查到此学号的学生,提示信息:"Not found!\n"
               **如果查询到该学生,输出格式:"%ld\t%.0f\n"
按优秀(90~100)、良好(80~89)、中等(70~79)、及格(60~69)、不及格(0~59)5个类别,统计每个类别的人数以及所占的百分比:
                **成绩<60输出格式:"<60\t%d\t%.2f%%\n"
                **成绩=100输出格式:"%d\t%d\t%.2f%%\n"
                **其他输出百分比格式:"%d-%d\t%d\t%.2f%%\n"

#include"stdio.h"
int input(unsigned long *p,float *q,int k)
{
   int i,j;
   printf("Input student's ID, name and score:\n");
   for (i=0;i< k;i++)
       scanf("%ld%f",p+i,q+i);
   return 0;
}
int cal(float *p,int k)
{
   int i;float sum=0,av=0;
   for (i=0;i< k;i++)
       sum+=*(p+i);
   av=sum/k;
   printf("sum=%.0f,aver=%.2f\n",sum,av);
   return 0;
}
int swap(unsigned long *p,float *q,int i,int j)
{
   unsigned long t1;float t2;
   t1=*(p+i);
   *(p+i)=*(p+j);
   *(p+j)=t1;
   t2=*(q+i);
   *(q+i)=*(q+j);
   *(q+j)=t2;
 
   return 0;
}
int sortsc(unsigned long *p,float *q,int k)
{
   int i,j,max;
   for (i=0;i< k-1;i++)
   {
       max=i;
       for (j=i+1;j< k;j++)
           if (*(q+j)>*(q+max)) max=j;
       swap(p,q,i,max);
   }
 
   return 0;
}
int sortst(unsigned long *p,float *q,int k)
{
   int i,j,max;
   for (i=0;i< k-1;i++)
   {
       max=i;
       for (j=i+1;j< k;j++)
           if (*(p+j)<*(p+max)) max=j;
       swap(p,q,i,max);
   }
 
   return 0;
}
int sebn(unsigned long *p,float *q,int k)
{
   unsigned long sc;
   int i,ans=k;
   printf("Input the number you want to search:\n");
   scanf("%ld",&sc);
   for (i=0;i< k;i++)
       if (*(p+i)==sc) ans=i;
   if (ans!=k) printf("%ld\t%.0f\n",*(p+ans),*(q+ans));
   else printf("Not found!\n");
 
   return 0;
}
int stan(float *q,int k)
{
   int num[6],i;
   for (i=0;i< 6;i++) num[i]=0;
   for (i=0;i< k;i++)
   {
       if (*(q+i)>99) {num[0]++;continue;}
       if (*(q+i)>89) {num[1]++;continue;}
       if (*(q+i)>79) {num[2]++;continue;}
       if (*(q+i)>69) {num[3]++;continue;}
       if (*(q+i)>59) {num[4]++;continue;}
                      {num[5]++;}
   }
   printf("<60\t%d\t%.2f%%\n",num[5],100.0*num[5]/k);
   printf("60-69\t%d\t%.2f%%\n",num[4],100.0*num[4]/k);
   printf("70-79\t%d\t%.2f%%\n",num[3],100.0*num[3]/k);
   printf("80-89\t%d\t%.2f%%\n",num[2],100.0*num[2]/k);
   printf("90-99\t%d\t%.2f%%\n",num[1],100.0*num[1]/k);
   printf("100\t%d\t%.2f%%\n",num[0],100.0*num[0]/k);
 
   return 0;
}
int main()
{
  int n,flag=1,a,i;
  float sc[30];
  unsigned long st[30];
  printf("Input student number(n<30):\n");
  scanf("%d",&n);
  while(flag)
  {
       printf("Management for Students' scores\n");
       printf("1.Input record\n");
       printf("2.Caculate total and average score of course\n");
       printf("3.Sort in descending order by score\n");
       printf("4.Sort in ascending order by number\n");
       printf("5.Search by number\n");
       printf("6.Statistic analysis\n");
       printf("7.List record\n");
       printf("0.Exit\n");
       printf("Please Input your choice:\n");
       scanf("%d",&a);
       switch (a)
       {
           case 1:
               input(st,sc,n);
               break;
           case 2:
               cal(sc,n);
               break;
           case 3:
               sortsc(st,sc,n);
               printf("Sort in descending order by score:\n");
               for (i=0;i< n;i++)
                   printf("%ld\t%.0f\n",st[i],sc[i]);
               break;
           case 4:
               sortst(st,sc,n);
               printf("Sort in ascending order by number:\n");
               for (i=0;i< n;i++)
                   printf("%ld\t%.0f\n",st[i],sc[i]);
               break;
           case 5:
               sebn(st,sc,n);
               break;
           case 6:
               stan(sc,n);
               break;
           case 7:
               for (i=0;i< n;i++)
                   printf("%ld\t%.0f\n",st[i],sc[i]);
               break;
           case 0:
               flag=0;
               printf("End of program!\n");
               break;
           default:
               printf("Input error!\n");
       }
 
  }
 
  return 0;
}
Avatar_small
Bihar Board 10th Que 说:
2022年8月17日 20:50

New Question Papers & New Model Papers for the Bihar Board's 10th Grade for 2023 Common & Private, Good news! Students who failed last year's exams can get their BSEB 10th Matric Important Question Paper 2023 from either our website or the Bihar board's official web domain. Here, we're going to give you all the information about the Bihar Class 10 Exam Paper. Bihar Board 10th Question Paper 2023 For high school students, the Bihar Secondary Examination will administer tests in the fields of Science, Arts, and Commerce. Additionally, it administers a number of departmental exams, including the Teacher Training Examination and the Diploma in Physical Education.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter