题解 | #公务员面试#
公务员面试
https://www.nowcoder.com/practice/f3a134908d5b41869f14f58307008a97
#include <stdio.h> int main() { int score[7] = {0},i,j,flag = 1,temp; float ave; while(scanf("%d %d %d %d %d %d %d", &score[0], &score[1], &score[2], &score[3], &score[4], &score[5], &score[6])!=EOF) { for(i = 0; i < 6;i++) { flag = 1; for(j = 0;j < 6-i;j++) { if(score[j] > score[j+1]) { temp = score[j+1]; score[j+1] = score[j]; score[j] = temp; flag = 0; } } if(flag) break; } for(i = 1;i < 6;i++) { ave += score[i]; } printf("%.2f\n", ave/5); ave = 0; temp = 0; } return 0; }