codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <stdio.h> void sort(int a[],int lengh) { int tmp,i; while (lengh-- >= 0) { for (i = 0; i < lengh; i++) { if (a[lengh] > a[i]) { tmp = a[lengh]; a[lengh] = a[i]; a[i] = tmp; } } } } int main(void) { int array[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; int i; int length = sizeof(array) / sizeof(array[0]); for (i = 0; i < length; i++) { printf("%d ", array[i]); } printf("\n"); sort(array, length); for (i = 0; i < length; i++) { printf("%d ", array[i]); } printf("\n"); return 0; }
Private
[
?
]
Run code
Submit