C语言数组,将元素中的数字从大到小排列
来源:互联网 发布:淘宝联盟显示已收货 编辑:程序博客网 时间:2024/06/05 18:25
#include <stdio.h>void main(){int scores[] = {543, 323, 32, 554, 11, 3, 112};int i;int j;int k;for(i=0;i<7;i++){for(j=i+1;j<7;j++){if(scores[i]<scores[j]){k=scores[i];scores[i]=scores[j];scores[j]=k;}}printf("%d ",scores[i]);}putchar('\n');}
阅读全文