Last active
April 29, 2016 15:04
-
-
Save poetries/2b5a68d45ce02bba3fd1175f1f279cb6 to your computer and use it in GitHub Desktop.
sort
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
void sort(int *a,int len) | |
{ | |
int i,j,t; | |
for( i = 0;i<len-1;++i) | |
{ | |
for(j = i+1;j<len;++j)//或者 j = 0;j<len-i-1;++j | |
{ | |
if(a[j] >a[j+1]) | |
{ | |
t = a[j]; | |
a[j] = a[j+1]; | |
a[j+1] = t; | |
} | |
} | |
} | |
} | |
void main() | |
{ | |
int a[6] = {10,2,8,-8,11,0}; | |
int i = 0; | |
sort(a,6); | |
for(i = 0; i<6;++i) | |
{ | |
printf("%d ",a[i]); | |
} | |
printf("\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment