学生管理系统实训

简介: 学生管理系统实训
#include<stdio.h>
#include<Windows.h>
#include<conio.h>
#define StudentNumber 30             //Maximum number of students
#define SubjectNumber 6              //Maximum number of subjects
#define NameLength 20                //Maximum number of name_length
typedef struct student{
    long int num;
    char name[NameLength];
    float score[SubjectNumber];
    float sum;
}STU;
STU s[StudentNumber];
int itemSelected=-1;
int n;                               //StudentNumber
int m;                               //SubjectNumber
void inputScore();                   //Enter basic information
void SortByGrade();
void printScore();
int Menu(){
    system("cls");
    printf("\n ==============Student achievement management system===============\n");
    printf("\t 1.Enter your student id number, name and grade for each subject\n");
    printf("\t 2.A league table is arranged according to each student's total score from highest to lowest\n");
    printf("\t 3.Output information about each student\n");
    printf("\t 0.Quit\n");
    printf("======================================================================\n");
    printf("Please select options:");
    scanf( "%d",&itemSelected);
    system("cls");
    return itemSelected;
}
void chose(int a){
    switch(a){
        case 1: inputScore(); break;
        case 2: SortByGrade();break;
        case 3: printScore();break;
        case 0: printf("About to exit program");
            exit(0);
        default: printf("Input error!");break;
    }
}
int main()
{
    char a;
    printf("Please enter the total number of students(n<%d):\n",StudentNumber);
    scanf("%d",&n);
    getchar();
    printf("Please enter the total number of subjects(m<%d):\n",SubjectNumber);
    scanf("%d",&m);
    getchar();
    system("cls");
    while(1){
        itemSelected=Menu();
        chose(itemSelected);
    }
}
void inputScore(){
    printf("\n===============================================\n");
    printf("Please input student ID, name and subject information (enter 0 to stop information input) \n");
    int i,j;
    for(i=0;i<n;i++){
        printf("Student id (8):");
        scanf("%ld",&s[i].num);
        if(s[i].num==0) break;
        getchar();
        printf("Name:");
        gets(s[i].name);
        printf("Please enter your scores for each subject:");
        s[i].sum=0;
        for(j =0;j<m;j++){
            scanf("%f",&s[i].score[j]);
            s[i].sum +=s[i].score[j];
        }
        system("cls");
    }
}
void SortByGrade(){                                       //Sorted from highest to lowest overall score
    STU temp;
    int i,j,k;
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {      if(s[j].sum<s[j+1].sum){
                temp=s[j];
                s[j]=s[j+1];
                s[j+1]=temp;
            }
        }
    }
    printf("\n============Sorted from highest to lowest overall score===========\n");
    for(j=0;j<n;j++){
        printf("The overall score ranking %d is:",j+1);
        for(k=0;k<NameLength;k++){
            printf("%c",s[j].name[k]);
        }
        printf("\nThe student's total score is:%.2f\n",s[j].sum);
    }
    getch();
}
void printScore(){
    printf("==============Below is the student information==============\n");
    int j,k,c;
    for(j=0;j<n;j++){
        printf("The student's student id is:%ld\n",s[j].num);
        printf("The student's name is:");
        for(k=0;k<NameLength;k++){
            printf("%c",s[j].name[k]);
        }
        printf("\nA student's scores for each subject is:\n");
        for(c=0;c<m;c++){
            printf("The %d subject score is:%.2f\n",c+1,s[j].score[c]);
        }
        printf("The student's total score is:%.2f",s[j].sum);
        printf("\n");
    }
    getch();
}
相关文章
|
前端开发 JavaScript Java
面试官:什么是防抖和节流?如何实现?应用场景?
面试官:什么是防抖和节流?如何实现?应用场景?
360 0
|
安全 Linux 网络安全
CentOS7下vsftpd over SSL/TLS加密传输配置实践
CentOS7下vsftpd over SSL/TLS加密传输配置实践
733 0
CentOS7下vsftpd over SSL/TLS加密传输配置实践
案例分享:Qt+FFmpeg录屏应用(支持帧率、清晰度设置)
案例分享:Qt+FFmpeg录屏应用(支持帧率、清晰度设置)
案例分享:Qt+FFmpeg录屏应用(支持帧率、清晰度设置)
|
开发工具 Linux 关系型数据库
|
5天前
|
云安全 人工智能 算法
以“AI对抗AI”,阿里云验证码进入2.0时代
三层立体防护,用大模型打赢人机攻防战
1341 4
|
2天前
|
存储 弹性计算 应用服务中间件
2026年阿里云服务器新手租用全流程完整步骤教程(最新版)
2026年阿里云服务器新手租用全流程完整步骤教程,阿里云服务器提供自定义租用、一键租用、云市场租用和活动租用四种核心方式,适配不同配置需求、技术能力和预算场景。无论是需要精准配置的专业用户,还是追求快速部署的新手,都能找到合适的租用方案。以下是详细的适用场景和操作流程,助力高效上云。
271 146
|
6天前
|
人工智能 Rust 运维
这个神器让你白嫖ClaudeOpus 4.5,Gemini 3!还能接Claude Code等任意平台
加我进AI讨论学习群,公众号右下角“联系方式”文末有老金的 开源知识库地址·全免费
|
2天前
|
弹性计算 固态存储 大数据
2026年阿里云服务器租用费用_阿里云最新轻量、ECS、GPU云服务器价格表
2026年阿里云服务器租用费用多少钱?小编通过查询全网最新关于阿里云服务器租用价格的资料,整理了今年最新的云服务器租用价格表,包括轻量应用服务器、云服务器ECS和GPU服务器。现在最新阿里云服务器租用费用价格表,轻量2核2G轻量服务器一年68元,折合5.6元1个月,新老用户同享99元一年服务器,2核4G5M服务器ECS优惠价199元一年(企业专享),2核4G4M轻量服务器298元一年,4核8G服务器955元一年,4核16G10M服务器70元1个月、210元3个月,8核32G服务器160元1个月、480元3个月,整理2026阿里云服务器租用费用价格表,包括一年优惠价格、一个月和1小时收费明细表:
225 152
|
5天前
|
机器学习/深度学习 安全 API
MAI-UI 开源:通用 GUI 智能体基座登顶 SOTA!
MAI-UI是通义实验室推出的全尺寸GUI智能体基座模型,原生集成用户交互、MCP工具调用与端云协同能力。支持跨App操作、模糊语义理解与主动提问澄清,通过大规模在线强化学习实现复杂任务自动化,在出行、办公等高频场景中表现卓越,已登顶ScreenSpot-Pro、MobileWorld等多项SOTA评测。
695 4