Update README.md

main
powf2zncv 1 year ago
parent 6c8553b0fc
commit 37f8df459d

@ -22,38 +22,21 @@ int main()
} }
步骤2 步骤2
#include <iostream> #include<stdio.h>
int main() int main()
{ {
struct student int num[3];
float math[3],physic[3],english[3],sum[3];
int i;
for(i=0;i<3;i++)
{ {
int number; scanf("%d %f %f %f",&num[i],&math[i],&physic[i],&english[i]);
float gaoshu; sum[i]=math[i]+physic[i]+english[i];
float dawu; }
float yy; for(i=0;i<3;i++)
float add; {
}student1, student2, student3; printf("%d %.1f %.1f %.1f %.1f\n",num[i],math[i],physic[i],english[i],sum[i]);
scanf("%d",&student1.number); }
scanf("%f",&student1.gaoshu);
scanf("%f",&student1.dawu);
scanf("%f",&student1.yy);
scanf("%d",&student2.number);
scanf("%f",&student2.gaoshu);
scanf("%f",&student2.dawu);
scanf("%f",&student2.yy);
scanf("%d",&student3.number);
scanf("%f",&student3.gaoshu);
scanf("%f",&student3.dawu);
scanf("%f",&student3.yy);
student1.add = (student1.gaoshu + student1.dawu + student1.yy);
student2.add = (student2.gaoshu + student2.dawu + student2.yy);
student3.add = (student3.gaoshu + student3.dawu + student3.yy);
printf("%d %f %f %f %f\n", student1.number, student1.gaoshu, student1.dawu, student1.yy, student1.add);
printf("%d %f %f %f %f\n", student2.number, student2.gaoshu, student2.dawu, student2.yy, student2.add);
printf("%d %f %f %f %f\n", student3.number, student3.gaoshu, student3.dawu, student3.yy, student3.add);
} }
步骤3 步骤3
int main() int main()
@ -482,176 +465,172 @@ scanf("%d",&changer1);
} }
步骤八 步骤八
#include<stdio.h> #include<stdio.h>
struct student{ #include<string.h>
int id; #define N 100
int class;
struct stu_info
{
char num[20];
char cls[20];
char name[20]; char name[20];
double score1; float math,physics,english,total;
double score2; };
double score3;
double score; struct stu_info stu[N];
}stu[7]; int top=0;
void xunwen(void){
void print_menu()
{
printf("1.input\n"); printf("1.input\n");
printf("2.delet\n"); printf("2.delete\n");
printf("3.select\n"); printf("3.select\n");
printf("4.order\n"); printf("4.order\n");
printf("5.output\n"); printf("5.output\n");
printf("6.quit\n"); printf("6.quit\n");
printf("please input your option\n"); printf("please input your option\n");
} }
void input(void){
int i,j; void print()
char str[3]; {
void zhixing(void); int i;
for(i=0;i<7;i++){ for(i=0;i<top;i++) printf("%s,%s,%s,%.1f,%.1f,%.1f,%.1f\n",stu[i].num,stu[i].cls,stu[i].name,stu[i].math,stu[i].physics,stu[i].english,stu[i].total);
printf("id ");
scanf("%d",&stu[i].id);
printf("class ");
scanf("%d",&stu[i].class);
printf("name ");
scanf("%s",stu[i].name);
printf("score1 ");
scanf("%lf",&stu[i].score1);
printf("score2 ");
scanf("%lf",&stu[i].score2);
printf("score3 ");
scanf("%lf",&stu[i].score3);
printf("continue?\n");
scanf("%s",str);
if(str[0]=='y')
continue;
else if(str[0]=='n')
break;
else
return;
}
for(i=0;i<7;i++){
stu[i].score=stu[i].score1+stu[i].score2+stu[i].score3;
}
xunwen();
zhixing();
}
void delet(struct student stu4[]){
void xunwen(void);
void zhixing(void);
int i,j,k,a,b,c;
char str[3];
scanf("%d",&a);
for(i=0;i<7;i++){
if(stu[i].id==a){
stu[i].id=0;
}
}
for(i=0;i<7;i++){
if(stu[i].id!=0)
printf("%d %d %s %.1f %.1f %.1f %.1f %.1f\n",stu[i].id,stu[i].class,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].score);
}
printf("continue?\n");
struct student *p=stu;
scanf("%s",str);
if(str[0]=='y')
delet(p);
else if(str[0]=='n')
xunwen();
zhixing();
} }
void select(struct student stu7[]){
void xunwen(void); void input()
void zhixing(void); {
int i,j,k,a,b,c=1; char op[20];
char str[3]; while(1)
scanf("%d",&a); {
if(a>100){ printf("Id ");
for(i=0;i<7;i++){ scanf("%s",stu[top].num);
if(stu7[i].id==a) printf("class ");
printf("%d %d %s %.1f %.1f %.1f %.1f\n",stu[i].id,stu[i].class,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].score); scanf("%s",&stu[top].cls);
c=0; printf("name ");
} scanf("%s",stu[top].name);
} printf("score1 ");
else if(a<100){ scanf("%f",&stu[top].math);
for(i=0;i<7;i++){ printf("score2 ");
if(stu7[i].class==a){ scanf("%f",&stu[top].physics);
printf("%d %d %s %.1f %.1f %.1f %.1f\n",stu[i].id,stu[i].class,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].score); printf("score3 ");
c=0; scanf("%f",&stu[top].english);
} stu[top].total=stu[top].math+stu[top].physics+stu[top].english;
} top++;
} printf("continue?\n");
if(c==1) do{
printf("there is no eligible student"); scanf("%s",op);
printf("continue?\n"); }while(strcmp(op,"yes")!=0&&strcmp(op,"no")!=0);
struct student *p=stu; if(strcmp(op,"no")==0) return;
scanf("%s",str); }
if(str[0]=='y'){
select(p);
}
else if(str[0]=='n'){
xunwen();
zhixing();
}
} }
void order(struct student stu2[]){
void zhixing(void); void del()
void output(void); {
int i,j,k=0,a,b,c; int i,d;
struct student temp; char key[20],op[20];
struct student stu1[7]; while(1)
for(i=0;i<7;i++){ {
stu1[i]=stu2[i]; i=0,d=0;
} scanf("%s",key);
for(i=0;i<6;i++){ while(i<top)
for(j=i+1;j<7;j++){ {
if(stu1[j].score>=stu1[i].score){ if(strcmp((stu+i)->num,key)==0||strcmp((stu+i)->name,key)==0)
temp=stu1[i]; {
stu1[i]=stu1[j]; d++;top--;
stu1[j]=temp; *(stu+i)=*(stu+i+d);
} }
} else
} {
for(i=1;i<30;i++){ *(stu+i)=*(stu+i+d);
for(j=0;j<7;j++){ i++;
if(stu1[j].class==i) }
stu2[k++]=stu1[j]; }
} print();
} printf("continue?\n");
for(i=0;i<7;i++){ do{
if(stu[i].id!=0){ scanf("%s",op);
printf("%d %s %d %.1f %.1f %.1f",stu[i].id,stu[i].class,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3); }while(strcmp(op,"yes")!=0&&strcmp(op,"no")!=0);
} if(strcmp(op,"no")==0) return;
} }
xunwen();
zhixing();
} }
void output(){
void zhixing(void); void select()
int i; {
for(i=0;i<7;i++){ int i,flag;
if(stu[i].id!=0) char key[20],op[20];
printf("%d %d %s %.1f %.1f %.1f %.1f\n",stu[i].id,stu[i].class,stu[i].name,stu[i].score1,stu[i].score2,stu[i].score3,stu[i].score); while(1)
{
flag=0;
scanf("%s",key);
for(i=0;i<top;i++)
{
if(strcmp((stu+i)->num,key)==0||strcmp((stu+i)->cls,key)==0)
{
flag=1;
printf("%s,%s,%s,%.1f,%.1f,%.1f,%.1f\n",stu[i].num,stu[i].cls,stu[i].name,stu[i].math,stu[i].physics,stu[i].english,stu[i].total);
}
}
if(!flag)
{
printf("there is no eligible student\n");
return;
}
printf("continue?\n");
do{
scanf("%s",op);
}while(strcmp(op,"yes")!=0&&strcmp(op,"no")!=0);
if(strcmp(op,"no")==0) return;
} }
xunwen();
zhixing();
} }
void quit(void){
return; void order()
} {
void zhixing(void){ int i,j;
int i; struct stu_info tmp;
scanf("%d",&i); for(i=0;i<top;i++)
struct student *p=stu; {
switch(i){ for(j=0;j<top-i-1;j++)
case 1:input();break; {
case 2:delet(p);break; if(strcmp((stu+j)->cls,(stu+j+1)->cls)==1||strcmp((stu+j)->cls,(stu+j+1)->cls)==0&&((stu+j)->total<(stu+j+1)->total))
case 3:select(p);break; {
case 4:order(p);break; tmp = *(stu+j);
case 5:output();break; *(stu+j) = *(stu+j+1);
case 6:quit();break; *(stu+j+1) = tmp;
}
}
} }
print();
return;
} }
int main(){
xunwen(); int main()
zhixing(); {
return 0; int op;
while(1)
{
print_menu();
scanf("%d",&op);
switch(op)
{
case(1):
input();
break;
case(2):
del();
break;
case(3):
select();
break;
case(4):
order();
break;
case(5):
print();
break;
case(6):
return 0;
}
}
} }

Loading…
Cancel
Save