From 35c7bd042a92b40facc0f31872cfb79b9e347538 Mon Sep 17 00:00:00 2001 From: pqfc6e4lh <407900437@qq.com> Date: Sun, 5 Nov 2023 11:50:56 +0800 Subject: [PATCH] ADD file via upload --- 步骤7(未完成).cpp | 161 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 步骤7(未完成).cpp diff --git a/步骤7(未完成).cpp b/步骤7(未完成).cpp new file mode 100644 index 0000000..8e8c6ca --- /dev/null +++ b/步骤7(未完成).cpp @@ -0,0 +1,161 @@ +#include +#include +void sortexam(char *b[],char *name[],int f[],float c[],float d[],float e[],float g[],int h,int n)/*༶ڳɼ*/ +{ + int i,j; + int t=0; + char a='0'; + char *p=&a; + float k=0; + for(i=h;i<=n;i++)/*ð*/ + for(j=h;j<=n-i;j++) + { + if(g[j]f[j+1]) + { + t=f[j];/**/ + f[j]=f[j+1]; + f[j+1]=t; + p=b[j]; + b[j]=b[j+1]; + b[j+1]=p; + p=name[j]; + name[j]=name[j+1]; + name[j+1]=p; + k=c[j]; + c[j]=c[j+1]; + c[j+1]=k; + k=d[j]; + d[j]=d[j+1]; + d[j+1]=k; + k=e[j]; + e[j]=e[j+1]; + e[j+1]=k; + k=g[j]; + g[j]=g[j+1]; + g[j+1]=k; + } + } +} +int deletename(char *b[],char *name[],int f[],float c[],float d[],float e[],float g[],int n)/*ɾ*/ +{ + int i,j; + int k;/*泤*/ + k=n; + char a[1001]; + gets(a); + for(i=1;i<=n;i++) + { + if(strcmp(b[i],a)==0||strcmp(name[i],a)==0)/*Ƚ*/ + { + k--; + for(j=i;j<=n;j++) + { + b[j]=b[j+1]; + name[j]=name[j+1]; + f[j]=f[j+1]; + c[j]=c[j+1]; + d[j]=d[j+1]; + e[j]=e[j+1]; + g[j]=g[j+1]; + } + } +} +return k; +} +char *change(char *b[],char *name[],int f[],float c[],float d[],float e[],float g[],int n)/*޸ij*/ +{ + int i; + char *sign1;/*޸ijı*/ + char a[10001],a1[10001]; + int a2; + float a4,a5,a6; + scanf("%s %d %s %f %f %f",&a,&a2,&a1,&a4,&a5,&a6); + for(i=1;i<=n;i++) + { + if(strcmp(b[i],a)==0) + { + sign1=b[i]; + name[i]=a1; + f[i]=a2; + c[i]=a4; + d[i]=a5; + e[i]=a6; + g[i]=g[i+1]; + } +} +return sign1; +} +void print(char *b[],char *name[],int f[],float c[],float d[],float e[],float g[],int n,char *sign1)/**/ +{ + int i; +for(i=1;i<=n;i++) +{ + if(f[i]!=f[i-1]) + printf("%d %s %s %.1f %.1f %.1f",f[i],b[i],name[i],c[i],d[i],e[i]); + else + printf(" %s %s %.1f %.1f %.1f",b[i],name[i],c[i],d[i],e[i]); + if(strcmp(b[i],sign1)==0) + printf(" modified"); + printf("\n"); +} +} +int main() +{ + char s[1001]; + int i; + int k; + char *sign1; + int n=3; + char *b[1001]={"0","10001","10002","10003","0"};/*ѧ*//*ѧղʹ*/ + char *name[1001]={"0","Zhang","Yang","Liang","0"};/**/ + int f[1001]={0,11,12,11};/*༶*/ + float c[1001]={0,99.5,77.9,92.5},d[1001]={0,88.5,56.5,99.0},e[1001]={0,89.5,87.5,60.5};/*ɼ*/ + float g[1001]={0};/*ܳɼ*/ + sign1=change(b,name,f,c,d,e,g,3); + for(i=1;i<=3;i++) + g[i]=c[i]+d[i]+e[i]; + sortclass(b,name,f,c,d,e,g,n); + k=1;/*ǰ*/ + for(i=1;i<=n;i++) + { + if(f[i+1]!=f[k]) + { + sortexam(b,name,f,c,d,e,g,k,i); + k=i+1; +} +} +print(b,name,f,c,d,e,g,n,sign1); +return 0; +}