学生管理系统功能:插入一个学生,年龄,成绩)删除一个学生(根据姓名删修改学生成绩(根据姓名修改成绩)查询学生成绩(根据姓名查询成绩,遍历所有学生的成成绩进行排序(从高到低排序)

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct Student {
    char name[20];
    int age;
    char sex;
    int score;
};
void set_init( struct Student *stu_p)
{
    int i;
    for (i = 0; i < LEN; i++) {
        scanf("%s %d %c %d", stu_p[i].name,
                        &stu_p[i].age,
                        &stu_p[i].sex,
                        &stu_p[i].score);
    }
}
void sort(struct Student *stu_p) {
    int i, j, flag;
    struct Student temp;
    for (i = 0; i < LEN-1; i++) {
        for (flag = 0, j = 0; j < LEN - i - 1; j++) {
            if (stu_p[j].score > stu_p[j+1].score) {
                temp = stu_p[j];
                stu_p[j] = stu_p[j+1];
                stu_p[j+1] = temp;
                flag = 1;
            }
        }
        if ( flag == 0) {
            break;
        }
    }
}
void show( struct Student *stu_p)
{
    int i;
    for (i = 0; i < LEN; i++) {
        printf("姓名:%s\t年龄:%d\t性别:%c\t成绩:%d\n", stu_p[i].name,
                        stu_p[i].age,
                        stu_p[i].sex,
                        stu_p[i].score);
    }
}
int main(int argc, const char *argv[])
{
struct Student stu_arr[LEN] = {0};
    set_init( stu_arr);
    sort(stu_arr);
    show(stu_arr);
    return 0;
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值