From f130757b9c39d2c8741b1ec4e718af4952828564 Mon Sep 17 00:00:00 2001 From: p56isruwj <3475735425@qq.com> Date: Mon, 13 Nov 2023 22:30:34 +0800 Subject: [PATCH] ADD file via upload --- 学籍管理系统步骤4.c | 55 +++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 学籍管理系统步骤4.c diff --git a/学籍管理系统步骤4.c b/学籍管理系统步骤4.c new file mode 100644 index 0000000..26b3143 --- /dev/null +++ b/学籍管理系统步骤4.c @@ -0,0 +1,55 @@ +#include +#include +#define N 3 + +struct stu_info +{ + char num[10]; + int cls,flag; + float maths,physics,english; +}; + +struct stu_info stu[N+1]={{"10001",11,0,99.5,88.5,89.5}, + {"10002",12,0,77.9,56.5,87.5}, + {"10003",11,0,92.5,99.0,60.5}}; + +void sort(struct stu_info *stu,int n) +{ + int i,j; + struct stu_info tmp; + for(i=0;icls>(stu+j+1)->cls)||((stu+j)->cls==(stu+j+1)->cls)&&((stu+j)->num>(stu+j+1)->num)) + { + tmp = *(stu+j); + *(stu+j) = *(stu+j+1); + *(stu+j+1) = tmp; + } + } + } + return; +} + +int main() +{ + scanf("%s",&stu[3].num); + scanf("%d",&stu[3].cls); + scanf("%f",&stu[3].maths); + scanf("%f",&stu[3].physics); + scanf("%f",&stu[3].english); + stu[3].flag=1; + int i; + sort(stu,N+1); + for(i=0;i