zoukankan      html  css  js  c++  java
  • C语言学生成绩管理系统

    1.学生成绩管理系统V1.0

    某班有最多不超过40人(具体人数由键盘输入)参加某门课程的考试,用一维数组作函数参数编程实现如下学生成绩管理:

    (1)录入每个学生的学号和考试成绩;

    (2)计算课程的总分和平均分;

    (3)按成绩由高到低排出名次表;

    (4)按学号由小到大排出成绩表;

    (5)按学号查询学生排名及其考试成绩;

    (6)按优秀(90-100)、良好(80-89)、中等(70-79)、及格(60-69)、不及格(0-59)5个类别,统计每个类别的人数以及所占的百分比;

    (7)输出每个学生的学号、考试成绩,课程总分和平均分。

    2.学生成绩管理系统V1.1

    在学生成绩管理系统V1.0的基础上,要求程序运行后先显示如下菜单,并提示用户输入选项:

    (1)Append record

    (2)Calculate 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

    (8)Exit

      1 #include<stdio.h>
      2 #include<stdlib.h>
      3 #define N 40
      4 void ReadScore(int score[],long num[],int n); /*输入成绩*/
      5 void ScoreSum(int score[],int n); /*计算总分*/
      6 void ScoreAverage(int score[],int n); /*计算平均分*/
      7 void DataSort(int score[],long num[],int n); /*按成绩由高到低排名*/
      8 void PrintDataSort(int score[],long num[],int n);/*按成绩由高到低输出*/
      9 void NumSort(int score[],long num[],int n);/*按学号由小到大排名*/
     10 void PrintNumSort(int score[],long num[],int n);/*按学号由小到大输出*/
     11 void Search(int score[],long num[],int n); /*按学号查询排名及考试成绩*/
     12 void Analysis(int score[],int n); /*统计类别人数及百分比*/
     13 void List(int score[],long num[],int n); /*输出每个学生的学号、考试成绩,课程总分和平均分*/
     14 
     15 int main(void) {
     16     int score[N],n,m;
     17     long num[N];
     18     do {
     19         printf("1.Append record
    ");
     20         printf("2.Calculate total and average score of course
    ");
     21         printf("3.Sort in descending order by score
    ");
     22         printf("4.Sort in ascending order by number
    ");
     23         printf("5.Search by number
    ");
     24         printf("6.Statistic analysis
    ");
     25         printf("7.List record
    ");
     26         printf("8.Exit
    ");
     27         printf("Input serial number:");
     28         scanf("%d",&m);
     29         switch (m) {
     30             case 1: {
     31                 printf("Input n:");
     32                 scanf("%d",&n);
     33                 ReadScore(score,num,n);
     34                 break;
     35             }
     36             case 2: {
     37                 ScoreSum(score,n);
     38                 ScoreAverage(score,n);
     39                 break;
     40             }
     41             case 3: {
     42                 DataSort(score,num,n);
     43                 PrintDataSort(score,num,n);
     44                 break;
     45             }
     46             case 4: {
     47                 NumSort(score,num,n);
     48                 PrintNumSort(score,num,n);
     49                 break;
     50             }
     51             case 5: {
     52                 Search(score,num,n);
     53                 break;
     54             }
     55             case 6: {
     56                 Analysis(score,n);
     57                 break;
     58             }
     59             case 7: {
     60                 List(score,num,n);
     61                 break;
     62             }
     63             case 8:{
     64                 printf("Exit");
     65                 break;
     66             } 
     67             default:
     68                 printf("Please enter it again.");
     69         }
     70         printf("
    ");
     71     } while(m!=8);
     72     return 0;
     73 }
     74 
     75 void ReadScore(int score[],long num[],int n) {
     76     int i;
     77     for(i=0; i<n; i++) {
     78         printf("Input ID and score:");
     79         scanf("%ld%d",&num[i],&score[i]);
     80     }
     81 }
     82 
     83 void ScoreSum(int score[],int n) {
     84     int i,sum=0;
     85     for(i=0; i<n; i++) {
     86         sum+=score[i];
     87     }
     88     printf("sum score is %d
    ",sum);
     89 }
     90 
     91 void ScoreAverage(int score[],int n) {
     92     int i,sum=0;
     93     for(i=0; i<n; i++) {
     94         sum+=score[i];
     95     }
     96     printf("average score is %.2f
    ",(float)sum/n);
     97 }
     98 
     99 void DataSort(int score[],long num[],int n) {
    100     int i,j,temp,k;
    101     for(i=0; i<n-1; i++) {
    102         for(j=i+1; j<n; j++) {
    103             if(score[j]>score[i]) {
    104                 temp=score[j];
    105                 score[j]=score[i];
    106                 score[i]=temp;
    107                 k=num[j];
    108                 num[j]=num[i];
    109                 num[i]=k;
    110             }
    111         }
    112     }
    113 }
    114 
    115 void PrintDataSort(int score[],long num[],int n) {
    116     int i;
    117     for(i=0; i<n; i++) {
    118         printf("%10ld%4d
    ",num[i],score[i]);
    119     }
    120     printf("
    ");
    121 }
    122 
    123 void NumSort(int score[],long num[],int n) {
    124     int i,j,temp,k;
    125     for(i=0; i<n-1; i++) {
    126         for(j=i+1; j<n; j++) {
    127             if(num[j]<num[i]) {
    128                 temp=score[j];
    129                 score[j]=score[i];
    130                 score[i]=temp;
    131                 k=num[j];
    132                 num[j]=num[i];
    133                 num[i]=k;
    134             }
    135         }
    136     }
    137 }
    138 
    139 void PrintNumSort(int score[],long num[],int n) {
    140     int i;
    141     for(i=0; i<n; i++) {
    142         printf("%10ld%4d
    ",num[i],score[i]);
    143     }
    144     printf("
    ");
    145 }
    146 
    147 void Search(int score[],long num[],int n) {
    148     int i,m=-1,count=1;
    149     long t;
    150     printf("Input ID:");
    151     scanf("%ld",&t);
    152     do{
    153         m++;
    154     }while(t!=num[m]);
    155     for(i=0; i<n; i++) {
    156         if(score[i]>score[m])
    157             count+=1;
    158     }
    159     printf("score is %d,rank is %d
    ",score[m],count);
    160 }
    161 
    162 void Analysis(int score[],int n) {
    163     int i;
    164     int a=0,b=0,c=0,d=0,e=0;
    165     for(i=0; i<n; i++) {
    166         if(score[i]>=90)
    167             a+=1;
    168         else if(score[i]>=80&&score[i]<90)
    169             b+=1;
    170         else if(score[i]>=70&&score[i]<80)
    171             c+=1;
    172         else if(score[i]>=60&&score[i]<70)
    173             d+=1;
    174         else
    175             e+=1;
    176     }
    177     printf("Excellent is %d,占 %.2f%%
    ",a,(float)a*100/n);
    178     printf("Good is %d,占 %.2f%%
    ",b,(float)b*100/n);
    179     printf("Medium is %d,占 %.2f%%
    ",c,(float)c*100/n);
    180     printf("Pass is %d,占 %.2f%%
    ",d,(float)d*100/n);
    181     printf("Failure is %d,占 %.2f%%
    ",e,(float)e*100/n);
    182 }
    183 
    184 void List(int score[],long num[],int n) {
    185     int i,sum=0;
    186     for(i=0; i<n; i++) {
    187         printf("%ld score is %d
    ",num[i],score[i]);
    188         sum+=score[i];
    189     }
    190     printf("Sum score is %d
    ",sum);
    191     printf("Average score is %.2f
    ",(float)sum/n);
    192 }
  • 相关阅读:
    flash 自定义右键功能
    本地和VMware虚拟主机之间的网络访问
    java: org.luaj.vm2.LuaError:XXX module not found lua脚本初始化出错
    火狐 提示“此连接是不受信任的” 可能是因为开启了其它抓包代理软件导致的
    批量导入数据库
    引用Interop.SQLDMO.dll后的注意事项。
    c# Invoke和BeginInvoke 区别
    闭包的7种形式
    C#使用ICSharpCode.SharpZipLib压缩后进行web批量下载文件
    C# Socket编程笔记
  • 原文地址:https://www.cnblogs.com/20201212ycy/p/14766051.html
Copyright © 2011-2022 走看看