#include <stdio.h>
int main(){float score[6],t;printf("请输入6名学生成绩:");for(int i = 0;i < 6;i++){scanf("%f",score + i);}for(int i = 1;i <= 6;i++){for(int j = 0;j < 6 - i;j++){if( score[j] > score[j+1] ){t = score[j];score[j] = score[j+1];score[j+1] = t;}}}printf("排序结果:");for(int i = 0;i < 6;i++){printf("%.1f ",score[i]);}printf("\n");return 0;
}
#include <stdio.h>
int main(){double score[10],t,ave,per;int max,n = 0;printf("请输入十名学生成绩:");for(int i = 0;i < 10;i++){scanf("%lf",score + i);}printf("原始成绩表:");for(int i = 0;i < 10;i++){printf("%lf ",score[i]);ave += score[i];}ave /= 10; for(int i = 0;i < 9;i++){max = i;for(int j = i + 1;j < 10;j++){if(score[max] < score[j]){ max = j;}if( j == 9 ){t = score[max];score[max] = score[i];score[i] = t;}} }printf("\n排序后的成绩:");for(int i = 0;i < 10;i++){printf("%lf ",score[i]);if(score[i] > ave){n = i + 1;}}printf("\n");printf("平均分为: %lf\n",ave);printf("大于平均分的比重为:%f%%\n",n*10.0);return 0;
}
#include <stdio.h>
#define N 6
int main(){int arr[N],t;for(int i = 0;i < N;i++){scanf("%d",arr + i);}for(int i = 1;i < N;i++){for(int j = 0;j < N - i;j++){if(arr[j] > arr[j+1]){t = arr[j];arr[j] = arr[j+1];arr[j+1] = t; }}}for(int i = 0;i < N;i++){printf("%d ",arr[i]);}return 0;
}
#include <stdio.h>
#define N 6
int main(){int arr[N],t;for(int i = 0;i < N;i++){scanf("%d",arr + i);}for(int i = 1;i < N;i++){for(int j = 0;j < N - i;j++){if(arr[j] > arr[j+1]){t = arr[j];arr[j] = arr[j+1];arr[j+1] = t; }}}for(int i = 0;i < N;i++){printf("%d ",arr[i]);}return 0;
}