Last active
June 16, 2017 04:09
-
-
Save serihiro/fa2975eaffebdf1f39a97f5ee687b5aa to your computer and use it in GitHub Desktop.
パタヘネ用サンプルコード
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 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