parent
							
								
									bfaded97a6
								
							
						
					
					
						commit
						542388fc4d
					
				| @ -0,0 +1,52 @@ | ||||
| ²åÈë | ||||
| #include <stdio.h> | ||||
| int main() | ||||
| { | ||||
| 	struct stud | ||||
| 	{ | ||||
| 		int num; | ||||
| 		int clas; | ||||
| 		float math; | ||||
| 		float phy; | ||||
| 		float eng; | ||||
| 	}t={}; | ||||
| 	struct stud stu[100]; | ||||
| 	stu[0]={10001,11,99.5,88.5,89.5}; | ||||
| 	stu[1]={10002,12,77.9,56.5,87.5}; | ||||
| 	stu[2]={10003,11,92.5,99.0,60.5}; | ||||
| 	scanf("%d %d %f %f %f",&stu[3].num,&stu[3].clas,&stu[3].math,&stu[3].phy,&stu[3].eng); | ||||
| 	int i,j; | ||||
| 	for(i=0;stu[i+2].num!=0;i++) | ||||
| 	{ | ||||
| 		if(stu[3].num==stu[i].num)stu[3]=t; | ||||
| 	} | ||||
| 	for(i=0;stu[i].num!=0;i++) | ||||
| 	{ | ||||
| 		if(stu[i+1].num!=0) | ||||
| 		{ | ||||
| 			for(j=i+1;stu[j].num!=0;j++) | ||||
| 			{ | ||||
| 				if(stu[i].num>stu[j].num) | ||||
| 				{ | ||||
| 					t=stu[i];stu[i]=stu[j];stu[j]=t; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	for(i=0;stu[i].num!=0;i++) | ||||
| 	{ | ||||
| 		if(stu[i+1].num!=0) | ||||
| 		{ | ||||
| 			for(j=i+1;stu[j].num!=0&&stu[i].clas==stu[j].clas;j++) | ||||
| 			{ | ||||
| 				if(stu[i].math+stu[i].phy+stu[i].eng<stu[j].math+stu[j].phy+stu[j].eng) | ||||
| 				{ | ||||
| 					t=stu[i];stu[i]=stu[j];stu[j]=t; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	for(i=0;stu[i].num!=0;i++) | ||||
| 	printf("%d %d %3.1f %3.1f %3.1f\n",stu[i].num,stu[i].clas,stu[i].math,stu[i].phy,stu[i].eng); | ||||
| 	return 0; | ||||
| } | ||||
					Loading…
					
					
				
		Reference in new issue