题解 | #统计成绩#
统计成绩
https://www.nowcoder.com/practice/cad8d946adf64ab3b17a555d68dc0bba
#include <stdio.h> int main() { int n; float sum = 0; float s[100]={0}; scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%f",&s[i]); sum = sum + s[i]; } for(int i=0;i<n-1;i++) { for(int j=0;j<n-1-i;j++) { if(s[j]>s[j+1]) { float tmp; tmp = s[j]; s[j] = s[j+1]; s[j+1] = tmp; } } } printf("%.2f %.2f %.2f",s[n-1],s[0],sum/n); return 0; }
冒泡排序