diff --git a/step4.c b/step4.c new file mode 100644 index 0000000..bb20f55 --- /dev/null +++ b/step4.c @@ -0,0 +1,83 @@ +#include +int main(){ + void SORT(float (*p)[5],int r); + int FIND(float m[][5],float a,int r); + float message[4][5]={{10001,11,99.5,88.5,89.5},{10002,12,77.9,56.5,87.5},{10003,11,92.5,99.0,60.5}}; + float *p,(*q)[5]; + int word=1,s; + for(s=0,p=&message[3][0];s<5;s++,p++){ + scanf("%f",p); + } + float sig=message[3][0]; + SORT(message,3); + int a=FIND(message,sig,3); + if(a!=3){ + printf("已存在学号的信息\n"); + for(s=1,p=&message[0][0];s<=15;s++,p++){ + if(s%5==0){ + printf("%.1f\n",*p); + } + else if(s%5==1||s%5==2){ + printf("%d ",(int)*p); + } + else{ + printf("%.1f ",*p); + + } + } + } + else{ + SORT(message,4); + a=FIND(message,sig,4)+1; + for(s=1,p=&message[0][0];s<=20;s++,p++){ + if(s==5*a){ + printf("%.1f inserted\n",*p); + } + else if(s%5==0){ + printf("%.1f\n",*p); + } + else if(s%5==1||s%5==2){ + printf("%d ",(int)*p); + } + else{ + printf("%.1f ",*p); + + } + } + } +} +void SORT(float (*p)[5],int r){ + int i,j,s; + for(i=1;i*(*(p+j+1)+1)){ + float a[5]; + for(s=0;s<5;s++){ + *(a+s)=*(*(p+j)+s); + *(*(p+j)+s)=*(*(p+j+1)+s); + *(*(p+j+1)+s)=*(a+s); + } + } + else if(*(*(p+j)+1)==*(*(p+j+1)+1)){ + float totalscore1=*(*(p+j)+2)+*(*(p+j)+3)+*(*(p+j)+4); + float totalscore2=*(*(p+j+1)+2)+*(*(p+j+1)+3)+*(*(p+j+1)+4); + if(totalscore1