1 #include<stdio.h> 2 3 int main() 4 { 5 int data[]={1,5,3,6,4,2}; 6 /*increase*/ 7 /* 8 int i=0; 9 for(;i<6-1;i++){ 10 int j=0; 11 for(;j<6-1-i;j++){ 12 if(data[j]>data[j+1]){ 13 int temp = data[j]; 14 data[j] = data[j+1]; 15 data[j+1] = temp; 16 } 17 18 } 19 }*/ 20 /*decrease*/ 21 int i=0; 22 for(;i<6-1;i++){ 23 int j=0; 24 for(;j<6-1-i;j++){ 25 if(data[j]<data[j+1]){ 26 int temp = data[j]; 27 data[j] = data[j+1]; 28 data[j+1] = temp; 29 } 30 31 } 32 } 33 34 for(i=0;i<6;i++){ 35 printf("%d",data[i]); 36 } 37 }