You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

139 lines
4.0 KiB

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Student{
int stunumber;
int class;
char name[10];
float grade1;
float grade2;
float grade3;
float sum;
}students[7]={
{10001,11,"Zhang",99.5,88.5,89.5,99.5+88.5+89.5},
{10002,12,"Yang",77.9,56.5,87.5,77.9+56.5+87.5},
{10003,11,"Liang",92.5,99.0,60.5,92.5+99.0+60.5},
{10004,11,"Cai",89.6,56.9,90.5,89.6+56.9+90.5},
{10005,14,"Fu",55.6,67.9,98.9,55.6+67.9+98.9},
{10006,12,"Mao",22.1,45.9,99.2,22.1+45.9+99.2},
{10007,13,"Zhan",35.6,67.9,88.0,35.6+67.9+88.60}};
//һϵ<D2BB><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int class_idx,min_idx,max_idx,i,n,j;
float sum_idx;
char name_idx[10];
void selection_sort(struct Student arr[], int n) {
int i, j, min_idx;
//һһ<D2BB><D2BB><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><E1B9B9><EFBFBD><EFBFBD>class<73><73>ֵ
for (i = 0; i < n-1; i++) {
// <20>ҵ<EFBFBD><D2B5><EFBFBD>Сֵ<D0A1><D6B5>λ<EFBFBD><CEBB>
min_idx = i;
for (j = i+1; j < n; j++)
{
if (arr[j].class < arr[min_idx].class)
{
min_idx = j;
}
else if(arr[j].class == arr[min_idx].class)
{
if(arr[j].sum > arr[min_idx].sum)
{
min_idx=j;
}
}
}
// ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
struct Student temp = arr[min_idx];
arr[min_idx] = arr[i];
arr[i] = temp;
}
}
void print_student(struct Student *s) {
printf("%d %d %s %.1f %.1f %.1f \n", s->stunumber, s->class, s->name, s->grade1, s->grade2, s->grade3);
}
int main(){
void selection_sort(struct Student arr[], int n);
void print_student(struct Student *s);
selection_sort(students,7);
int Section_idx;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
scanf("%d",&Section_idx);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
switch(Section_idx)
{
case 1:goto section1;break;
case 2:goto section2;break;
case 3:goto section3;break;
case 4:goto section4;break;
case 5:goto section5;break;
default:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
return 0;
section1://<2F><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><E0BCB6>Χ<EFBFBD>ڵ<EFBFBD>ѧ<EFBFBD><D1A7>
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD>༶-<2D><EFBFBD><E0BCB6>\n"); //<2F>༶-<2D>
scanf("%d-%d",&min_idx,&max_idx);
for(i=0;i < 7;i++)
{
if(students[i].class>=min_idx&&students[i].class<=max_idx)
{
printf("%d %d %s %.1f %.1f %.1f \n", students[i].stunumber, students[i].class, students[i].name, students[i].grade1, students[i].grade2, students[i].grade3);
}
}
return 0;
section2://<2F><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>ѧ<EFBFBD>ŷ<EFBFBD>Χ<EFBFBD><CEA7>ѧ<EFBFBD><D1A7>
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><>ţ<EFBFBD>\n"); //ѧ<><D1A7><><D1A7>
scanf("%d-%d",&min_idx,&max_idx);
for(i=0;i < 7;i++)
{
if(students[i].stunumber >= min_idx&&students[i].stunumber <= max_idx)
printf("%d %d %s %.1f %.1f %.1f \n", students[i].stunumber, students[i].class, students[i].name, students[i].grade1, students[i].grade2, students[i].grade3);
}
return 0;
section3://<2F><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>ͷ<EFBFBD><CDB7>ĸ<EFBFBD><C4B8>ѧ<EFBFBD><D1A7>
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD>ĸ+*<2A><>\n"); //<2F><>ĸ*
scanf("%s",name_idx);
for(i=0;i<7;i++)
{
n=strlen(name_idx)-1;
for(j=0;j<strlen(name_idx)-1;j++)
{
if(name_idx[j]==students[i].name[j])
{
n--;
}
}
if(n==0)
{
printf("%d %d %s %.1f %.1f %.1f \n", students[i].stunumber, students[i].class, students[i].name, students[i].grade1, students[i].grade2, students[i].grade3);
}
}
return 0;
section4://<2F><><EFBFBD>Ҵ<EFBFBD><D2B4><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>ܳɼ<DCB3><C9BC><EFBFBD>ѧ<EFBFBD><D1A7>
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD>ܳɼ<EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>\n"); //<2F>༶.ѧ<><D1A7><><D1A7>
scanf("%f",&sum_idx);
for(i = 0;i < 7;i++)
{
if(students[i].sum>=sum_idx)
{
printf("%d %d %s %.1f %.1f %.1f \n", students[i].stunumber, students[i].class, students[i].name, students[i].grade1, students[i].grade2, students[i].grade3);
}
}
return 0;
section5://<2F><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><E0BCB6>ָ<EFBFBD><D6B8>ѧ<EFBFBD>ŷ<EFBFBD>Χ<EFBFBD>ڵ<EFBFBD>ѧ<EFBFBD><D1A7>
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD>༶+.+ѧ<><D1A7><>ţ<EFBFBD>\n");
scanf("%d.%d-%d",&class_idx,&min_idx,&max_idx);
for(i = 0;i < 7;i++)
{
if(students[i].class==class_idx&&students[i].stunumber>=min_idx&&students[i].stunumber<=max_idx)
{
printf("%d %d %s %.1f %.1f %.1f \n", students[i].stunumber, students[i].class, students[i].name, students[i].grade1, students[i].grade2, students[i].grade3);
}
}
return 0;
}