Skip to content

Instantly share code, notes, and snippets.

@serihiro
Last active June 16, 2017 04:09
Show Gist options
  • Save serihiro/fa2975eaffebdf1f39a97f5ee687b5aa to your computer and use it in GitHub Desktop.
Save serihiro/fa2975eaffebdf1f39a97f5ee687b5aa to your computer and use it in GitHub Desktop.
パタヘネ用サンプルコード
#include <stdio.h>
void swap(int v[], int k){
int temp;
temp = v[k];
v[k] = v[k+1];
v[k+1] = temp;
}
void sort(int v[], int n){
int i,j;
for(i = 0; i < n; i++){
for(j = i - 1; j > 0 && v[j] > v[j+1]; j--){
swap(v, j);
}
}
}
int main(int argc, char ** argv){
int arr[10] = {1, 4, 5, 3, 2, 6, 2, 3, 4, 8};
sort(arr, 10);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment