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.
powf2zncv 69926135f0
Update README.md
1 year ago
README.md Update README.md 1 year ago

README.md

步骤1 int main() { char controll; char arr1[] = { " 1.Input" }; char arr2[] = { " 2.Output" }; char arr3[] = { " 3.Order" }; char arr4[] = { " 4.Quit" }; char arr5[] = { "You are trying to Input info" }; char arr6[] = { "You are trying to Output info" }; char arr7[] = { "You are trying to Make things ordered" }; char arr8[] = { "You are about to Quit" }; printf("%s\n%s\n%s\n%s\n", arr1, arr2, arr3, arr4); scanf_s("%c", &controll); switch (controll) { case 'i':printf("\n%s\n", arr5); break; case 'o':printf("\n%s\n", arr6); break; case 'm':printf("\n%s\n", arr7); break; case 'q':printf("\n%s\n", arr8); break; default:printf("Wrong input"); }

} 步骤2 #include<stdio.h> int main() { int num[3]; float math[3],physic[3],english[3],sum[3]; int i; for(i=0;i<3;i++) { scanf("%d %f %f %f",&num[i],&math[i],&physic[i],&english[i]); sum[i]=math[i]+physic[i]+english[i]; } for(i=0;i<3;i++) { printf("%d %.1f %.1f %.1f %.1f\n",num[i],math[i],physic[i],english[i],sum[i]); } }

步骤3 int main() { char controll; char arr1[] = { " 1.Input" }; char arr2[] = { " 2.Output" }; char arr3[] = { " 3.Order" }; char arr4[] = { " 4.Quit" }; char arr5[] = { "Please input info of the three students:" }; char arr7[] = { "You are trying to Make things ordered" }; char arr8[] = { "You are about to Quit" }; printf("%s\n%s\n%s\n%s\n", arr1, arr2, arr3, arr4); scanf_s("%c", &controll); switch (controll) { case 'i':printf("\n%s\n", arr5); break; case 'm':printf("\n%s\n", arr7); break; case 'q':printf("\n%s\n", arr8); break; default:printf("Wrong input"); } struct student { int number; float gaoshu; float dawu; float yy; float add; float aver; }student1, student2, student3,studenttemp; 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); student1.aver = student1.add / 3; student2.aver = student2.add / 3; student3.aver = student3.add / 3; if (student1.add > student2.add) { studenttemp = student1; student1 = student2; student2 = studenttemp; } if (student1.add > student3.add) { studenttemp = student1; student1 = student3; student3 = studenttemp; } if (student2.add > student3.add) { studenttemp = student2; student2 = student3; student3 = studenttemp; } printf("%d,%.1f,%.1f\n", student1.number, student1.add, student1.aver); printf("%d,%.1f,%.1f\n", student2.number, student2.add, student2.aver); printf("%d,%.1f,%.1f\n", student3.number, student3.add, student3.aver);

} 步骤四 #include <stdio.h> int num[4],cla[4]; float f[4],s[4],t[4],add[4]; int begin,sta; int n=4; int insert; void sort(float add[]) { int i,j,te; float zh; for(i=n-1;i>sta;i--) { if(add[i]>add[i-1]) { zh=add[i];add[i]=add[i-1];add[i-1]=zh; te=num[i];num[i]=num[i-1];num[i-1]=te; zh=f[i];f[i]=f[i-1];f[i-1]=zh; zh=s[i];s[i]=s[i-1];s[i-1]=zh; zh=t[i];t[i]=t[i-1];t[i-1]=zh; } } if(n!=sta+1) { sta++; sort(add);} }

void div(int clas[]) { int i,j,te; float zh; for(i=0;i<n-1;i++) { if(clas[i]>clas[i+1]) { te=clas[i];clas[i]=clas[i+1];clas[i+1]=te; zh=add[i];add[i]=add[i+1];add[i+1]=zh; te=num[i];num[i]=num[i+1];num[i+1]=te; zh=f[i];f[i]=f[i+1];f[i+1]=zh; zh=s[i];s[i]=s[i+1];s[i+1]=zh; zh=t[i];t[i]=t[i+1];t[i+1]=zh; } } if(n!=sta+1){ n--; div(clas);}

}

int main() { void sort(float add[]); void div(int clas[]); num[0]=10001;num[1]=10002;num[2]=10003; cla[0]=11;cla[1]=12;cla[2]=11; f[0]=99.5;f[1]=77.9;f[2]=92.5; s[0]=88.5;s[1]=56.5;s[2]=99.0; t[0]=89.5;t[1]=87.5;t[2]=60.5; for(int i=0;i<3;i++) { add[i]=f[i]+s[i]+t[i]; } scanf("%d",&num[3]); insert=num[3]; int in=num[3]; for(int i=0;i<3;i++){ if(in==num[i]){ printf("%d %d %f %f %f %f",num[i],cla[i],f[i],s[i],t[i],add[i]); return 0; } } scanf("%d",&cla[3]); scanf("%f",&f[3]); scanf("%f",&s[3]); scanf("%f",&t[3]); add[3]=f[3]+s[3]+t[3]; sta=0;begin=0; div(cla); n=4; int m; for(m=0;m<n;m++){ if(cla[m]!=cla[m+1]) break; } sta=m;begin=sta; sort(add); n=m+1; sta=0;begin=sta; sort(add); n=4; for(int j=0;j<n;j++){ printf("%d %d %f %f %f %f",num[j],cla[j],f[j],s[j],t[j],add[j]); if(num[j]==insert) printf(" insert\n"); else printf("\n"); }

} 步骤五 #include <stdio.h> #include <string.h> #include <stdlib.h> int num[4],cla[4]; float f[4],s[4],t[4],add[4]; int begin,sta; int n=3; int insert; char name[4][10]={{"Zhang"},{"Yang"},{"Liang"}}; void sort(float add[]) { int i,j,te; float zh; char oo[10]; for(i=n-1;i>sta;i--) { if(add[i]>add[i-1]) { zh=add[i];add[i]=add[i-1];add[i-1]=zh; te=num[i];num[i]=num[i-1];num[i-1]=te; zh=f[i];f[i]=f[i-1];f[i-1]=zh; zh=s[i];s[i]=s[i-1];s[i-1]=zh; zh=t[i];t[i]=t[i-1];t[i-1]=zh; strcpy(oo,name[i]);strcpy(name[i],name[i-1]); strcpy(name[i-1],oo); } } if(n!=sta+1) { sta++; sort(add);} }

void div(int clas[]) { int i,j,te; float zh; char oo[10]; for(i=0;i<n-1;i++) { if(clas[i]>clas[i+1]) { te=clas[i];clas[i]=clas[i+1];clas[i+1]=te; zh=add[i];add[i]=add[i+1];add[i+1]=zh; te=num[i];num[i]=num[i+1];num[i+1]=te; zh=f[i];f[i]=f[i+1];f[i+1]=zh; zh=s[i];s[i]=s[i+1];s[i+1]=zh; zh=t[i];t[i]=t[i+1];t[i+1]=zh; strcpy(oo,name[i]);strcpy(name[i],name[i+1]); strcpy(name[i+1],oo); } } if(n!=sta+1){ n--; div(clas);}

}

int main() { void sort(float add[]); void div(int clas[]); num[0]=10001;num[1]=10002;num[2]=10003; cla[0]=11;cla[1]=12;cla[2]=11; f[0]=99.5;f[1]=77.9;f[2]=92.5; s[0]=88.5;s[1]=56.5;s[2]=99.0; t[0]=89.5;t[1]=87.5;t[2]=60.5; sta=0;begin=0; div(cla); n=3; int m; for(m=0;m<n;m++){ if(cla[m]!=cla[m+1]) break; } sta=m;begin=sta; sort(add); n=m+1; sta=0;begin=sta; sort(add); n=3; //scanf("delete"); printf("请输入要删除的学生信息(学号或姓名)\n"); scanf("%s",name[3]); int exist=0,target; if(name[3][0]>='0'&&name[3][0]<='9') { int number=atoi(name[3]); for(int i=0;i<3;i++){ if(number==num[i]){ printf("Are you sure(yes)?\n"); exist=1; target=i; break; } } } else { for(int i=0;i<3;i++){ if(strcmp(name[i],name[3])); else{ printf("Are you sure(yes)?\n"); exist=1; target=i; break; } } } char ch; if(exist==1){ scanf(" %c",&ch); if(ch=='y'){ for(int i=0;i<3;i++){ if(i!=target){ printf("%d %d %s %.2f %.2f %.2f\n",num[i],cla[i],name[i],f[i],s[i],t[i]); } } } if(ch=='n'){ for(int i=0;i<3;i++){ printf("%d %d %s %.2f %.2f %.2f\n",num[i],cla[i],name[i],f[i],s[i],t[i]); } } } else{ for(int i=0;i<3;i++){ printf("%d %d %s %.2f %.2f %.2f\n",num[i],cla[i],name[i],f[i],s[i],t[i]); } } return 0; } 步骤六 #include<stdio.h> struct Scoreb{ int schoolnumber; int classnumber; char name[20]; float math; float physics; float english; float sum; }; int main(){ struct Scoreb student1={10001,11,"Zhang",99.5,88.5,89.5,277.5}; struct Scoreb student2={10002,12,"Yang",77.9,56.5,87.5,221.9}; struct Scoreb student3={10003,11,"Liang",92.5,99.0,60.5,252}; struct Scoreb students[3] = {student1,student2,student3};

struct Scoreb schange;
scanf("%d%d%s%f%f%f",&schange.schoolnumber,&schange.classnumber,&schange.name,&schange.math,&schange.physics,&schange.english);int c=schange.schoolnumber;
for(int i=0;i<3;i++){
	if(schange.schoolnumber==students[i].schoolnumber){
		schange.sum = schange.math+schange.physics+schange.english;
		students[i]=schange;
	}	
}

for(int j = 0 ; j < 3 ; j++)
	for(int k = 2; k > j;k--){
		if(students[k].classnumber <students[k-1].classnumber){
			struct Scoreb temp1 = students[k-1];
			students[k-1] = students[k];
			students[k] = temp1;
		
		}else if(students[k].classnumber == students[k-1].classnumber){
			if(students[k].sum>students[k-1].sum){
			struct Scoreb temp2 = students[k-1];
			students[k-1] = students[k];
			students[k] = temp2;
			}
		}
	}
 
for(int i = 0; i < 2 ; i++){
	printf("%d %d %s %.1f %.1f %.1f ",students[i].classnumber,students[i].schoolnumber,students[i].name,students[i].math,students[i].physics,students[i].english);
	if(c==students[i].schoolnumber)
	printf("modified\n");
	if(students[0].classnumber==students[1].classnumber)
	{
	printf("   %d %s %.1f %.1f %.1f\n",students[1].schoolnumber,students[1].name,students[1].math,students[1].physics,students[1].english);break;}
}
printf("%d %d %s %.1f %.1f %.1f\n",students[2].classnumber,students[2].schoolnumber,students[2].name,students[2].math,students[2].physics,students[2].english);
if(c==students[2].schoolnumber)
printf(" modified");
return 0; 

}

步骤七 #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> #define N 100

struct stu_info { char num[20]; char cls[20]; char name[20]; float math,physics,english,total; };

struct stu_info stu[N]; int top=0;

void print_menu() { printf("1.input\n"); printf("2.delete\n"); printf("3.select\n"); printf("4.order\n"); printf("5.output\n"); printf("6.quit\n"); printf("please input your option\n"); }

void print() { int 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); }

void input() { char op[20]; while(1) { printf("Id "); scanf("%s",stu[top].num); printf("class "); scanf("%s",&stu[top].cls); printf("name "); scanf("%s",stu[top].name); printf("score1 "); scanf("%f",&stu[top].math); printf("score2 "); scanf("%f",&stu[top].physics); printf("score3 "); scanf("%f",&stu[top].english); stu[top].total=stu[top].math+stu[top].physics+stu[top].english; top++; printf("continue?\n"); do{ scanf("%s",op); }while(strcmp(op,"yes")!=0&&strcmp(op,"no")!=0); if(strcmp(op,"no")==0) return; } }

void del() { int i,d; char key[20],op[20]; while(1) { i=0,d=0; scanf("%s",key); while(i<top) { if(strcmp((stu+i)->num,key)==0||strcmp((stu+i)->name,key)==0) { d++;top--; (stu+i)=(stu+i+d); } else { (stu+i)=(stu+i+d); i++; } } print(); printf("continue?\n"); do{ scanf("%s",op); }while(strcmp(op,"yes")!=0&&strcmp(op,"no")!=0); if(strcmp(op,"no")==0) return; } }

void select() { int i,flag; char key[20],op[20]; 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; } }

void order() { int i,j; struct stu_info tmp; for(i=0;i<top;i++) { for(j=0;j<top-i-1;j++) { 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)) { tmp = *(stu+j); *(stu+j) = *(stu+j+1); *(stu+j+1) = tmp; } } } print(); return; }

int main() { 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; } } }