C语言_数字排列顺序
1 #include <stdio.h> 2 #include <stdlib.h> 3 #define LENGTH 8 4 5 void main() { 6 int i, j, tmp, number[LENGTH] = { 95, 45, 15, 78, 84, 51, 24, 12 }; 7 8 for (i = 0; i < LENGTH; i++) { 9 for (j = LENGTH - 1; j > i; j--) { 10 if (number[j] < number[j - 1]) { 11 tmp = number[j - 1]; 12 number[j - 1] = number[j]; 13 number[j] = tmp; 14 } 15 } 16 } 17 18 for (i = 0; i < LENGTH; i++) { 19 printf("%d ", number[i]); 20 printf("\n"); 21 } 22 23 system("pause ->nul"); 24 }
网名:浩秦;
邮箱:root#landv.pw;
博客:landv.cnblogs.com;
只要我能控制一個國家的貨幣發行,我不在乎誰制定法律。金錢一旦作響,壞話隨之戛然而止。