Update README.md

main
powf2zncv 1 year ago
parent 93365bf730
commit 69926135f0

@ -396,7 +396,155 @@ struct Scoreb student1={10001,11,"Zhang",99.5,88.5,89.5,277.5};
}
步骤七
#include <stdio.h>
#include <string.h>
struct student
{
int number;
int clas;
char name[10];
float grade1;
float grade2;
float grade3;
float sum;
int signal;
}student[7]={{10001,11,"Zhang",99.5,88.5,89.5,0,0},
{10002,12,"Yang",77.9,56.5,87.5,0,0},
{10003,11,"Liang",92.5,99.0,60.5,0,0},
{10004,11,"Cai",89.6,56.9,90.5,0,0},
{10005,14,"Fu",55.6,67.9,98.9,0,0},
{10006,12,"Mao",22.1,45.9,99.2,0,0},
{10007,13,"Zhan",35.6,67.9,88.0,0,0}
};
struct student temp;
void clas();
void number();
void name();
void grade();
void classandnumber();
const int n=7;
int main()
{
int identity;
scanf("%d",&identity);
for(int i=0;i<7;i++)
{
student[i].sum=student[i].grade1+student[i].grade2+student[i].grade3;
}
int i,j,k;
for(i=0;i<n-1;i++)
{
k=i;
for(j=i+1;j<n;j++)
{
if(student[j].clas<student[k].clas)
{
k=j;
}
else if(student[j].clas==student[k].clas)
{
if(student[j].sum>student[k].sum)
{
k=j;
}
}
}
temp=student[k];
student[k]=student[i];
student[i]=temp;
}
switch(identity)
{
case 1:clas();break;
case 2:number();break;
case 3:name();break;
case 4:grade();break;
case 5:classandnumber();break;
default:printf("Wrong input!\n");
}
for(i=0;i<n;i++)
{
if(student[i].signal!=0)
{
printf("%6d %3d %8s %6.1f %6.1f %6.1f\n",student[i].number,student[i].clas,student[i].name,student[i].grade1,student[i].grade2,student[i].grade3);
}
}
return 0;
}
void clas()
{
int inf,noun,sup;
scanf("%d%c%d",&inf,&noun,&sup);
printf("%d %d",inf,sup);
for(int i=0;i<7;i++)
{
if(student[i].clas>=inf&&student[i].clas<=sup)
student[i].signal=1;
}
}
void number()
{
int inf,noun,sup;
scanf("%d%c%d",&inf,&noun,&sup);
for(int i=0;i<7;i++)
{
if(student[i].number>=inf&&student[i].number<=sup)
student[i].signal=1;
}
}
void name()
{
int i=0,k,count;
char initial[10];
scanf("%s",initial);
printf("%s\n",initial);
count=strlen(initial);
bool flag=true;
for(int i=0;i<n;i++)
{
for(int j=0;j<count-2;j++)
{
if(student[i].name[j]!=initial[j])
flag=false;
}
if(flag)
{
student[i].signal=1;
}
}
}
void grade()
{
int inf;
scanf("%d",&inf);
for(int i=0;i<7;i++)
{
if(student[i].sum>=inf)
student[i].signal=1;
}
}
void classandnumber()
{
int clas,noun1,inf,noun2,sup;
scanf("%d%c%d%c%d",&clas,&noun1,&inf,&noun2,&sup);
for(int i=0;i<7;i++)
{
if(student[i].clas==clas)
{
if(student[i].number>=inf&&student[i].number<=sup)
student[i].signal=1;
}
}
}
步骤八
#include<stdio.h>
#include<string.h>

Loading…
Cancel
Save