#include #include #include typedef struct Student{ char id[100]; int cl; char name[100]; float score1; float score2; float score3; float total_score; }Student; void getinput(int *type,int *p1,int *p2,int *p3){ scanf("%d",type); if(*type==1||*type==2){ scanf("%d-%d",p1,p2); }else if(*type==3){ char temp[20]; scanf("%s",temp); *p1=temp[0]; }else if(*type==5){ scanf("%d.%d-%d",p1,p2,p3); }else{ scanf("%d",p1); } } void query(Student *students,int numStudents,int type,int p1,int p2,int p3,Student *results,int *numResults){ int i; *numResults = 0; char temp1[20], temp2[20],temp3[20]; sprintf(temp1, "%d", p1); sprintf(temp2, "%d", p2);//格式化数据写入临时字符串 sprintf(temp3,"%d",p3); for(i=0; i=p1&&students[i].cl<=p2){ results[(*numResults)++] = students[i];//班级号在p1-p2内 } break; case 2: if(strcmp(students[i].id,temp1)>=0 && strcmp(students[i].id,temp2)<=0){ results[(*numResults)++] = students[i];//学号在p1-p2内 } break; case 3: if(students[i].name[0]==p1){ results[(*numResults)++] = students[i];//名字以特定字母开头的学生 } break; case 4: if(students[i].total_score>=p1){ results[(*numResults)++] = students[i];//总分大于等于特定分数的学生 } break; case 5: if(students[i].cl==p1 && strcmp(students[i].id,temp2)>=0 && strcmp(students[i].id,temp3)<= 0){ results[(*numResults)++] = students[i];//特定班级、特定学号范围的学生 } break; } } } void sort(Student student[],int n){ int i,j; for(i=0;istudent[j + 1].cl||(student[j].cl==student[j + 1].cl&&student[j].total_score