学生管理系统

#include<stdio.h>
#include<string.h>
void menu() {
    printf("**********************学生管理系统**************\n");
    printf("**************选项1*****学生信息录入************\n");
    printf("**************选项2*****查看学生信息************\n");
    printf("**************选项3*****成绩最好学生信息********\n");
    printf("**************选项4*****按姓名进行升序**********\n");
    printf("**************选项5*****按成绩进行升序**********\n");
    printf("**************选项6*****退出********************\n");
}
void SendStuInformation(char Stud[][20], int n, int Score[]) {
    printf("请输入学生姓名和成绩\n");
    for (int i = 0; i < n; i++) {
        printf("请输入第%d名学生的信息", i);
        scanf("%s%d", Stud[i], &Score[i]);
    }

}
void CheckStuInformation(char Stud1[][20], int n, int Score1[]) {

    for (int i = 0; i < n; i++) {
        printf("第%d名学生的姓名为%s 和成绩为%d\n", i, Stud1[i], Score1[i]);
    }
    /*    else
            printf("sending option1 again");*/

}
void greatestStuInformation(char Stud1[][20], int n, int score[]) {
    int temp = score[0]; int k = 0;
    for (int i = 0; i < n; i++) {
        if (temp < score[i]) {
            temp = score[i];
            k++;
        }
    }
    printf("%s and %d", Stud1[k], temp);
}
void  fun1(char stu[][20], int n, int score[]) {
    char max[20] = ""; int temp = 0, k = 0; char temp1[20] = "";
        
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < n - i; j++) {

            if (strcmp(stu[j], stu[j + 1]) < 0) {
                strcpy(temp1, stu[j]);
                strcpy(stu[j], stu[j + 1]);
                strcpy(stu[j + 1], temp1);
                temp=score[j+1];
                score[j+1]=score[j];
                score[j]=temp;
            }

        }
    }
    for (int i = 0; i < n; i++) {
        printf("%s and %d\n", stu[i], score[i]);
    }
}
void fun2(char stu[][20], int n, int score[]) {
    int max = score[0]; int temp = 0, k = 0; char temp1[20] = "";
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < n - i; j++) {
            if (score[j] < score[j + 1]) {
                temp = score[j + 1];
                score[j + 1] = max;
                max = temp;
                strcpy(temp1, stu[j]);
                                strcpy(stu[j], stu[j + 1]);
                                strcpy(stu[j + 1], temp1);

            }
        }
    }
    for (int i = 0; i < n; i++) {
        printf("%s and %d\n", stu[i], score[i]);
    }

}
int main() {
    char Stu[5][20] = { 0 };
    int score[5] = { 0 };
    while (1)
    {
        int a;
        menu();
        printf("sending option=>>");
        scanf("%d", &a);
        switch (a) {
        case 1: {
            SendStuInformation(Stu, 5, score);
        }break;
        case 2: {
            CheckStuInformation(Stu, 5, score);
        }break;
        case 3: {
            greatestStuInformation(Stu, 5, score);
        }break;
        case 4: {
            fun1(Stu, 5, score);
        }break;
        case 5: {
            fun2(Stu, 5, score);
        }break;
        case 6:goto END;
        default: printf("sending option again");

        }

    }
END:
}

  • 11
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值