Selection Sort
Binary Search
Hanoi Tower
void sort(int list[], int n) {
int min;
for(int i=0; i<n-1; i++) {
min = i;
for(int j=i+1; j<n; j++)
if(list[j] < list[min])
min = j;
swap(list[i], list[min]);
}
}
int binsearch(int list[], int target, int l, int r) {
int mid;
if(l<=r) {
mid = (l+r)/2;
switch(COMPARE(list[mid], target)) {
case -1:
return binsearch(list, target, mid+1, r);
case 0:
return mid;
case 1:
return binsearch(list, target, l, mid-1);
}
}
return -1;
}
void TowerOfHanoi(int n, int start, int end, int temp) {
if(n==1) {
count++;
printf("%d번 실행: %d -> %d\\n", couint, start, end);
}
else {
TowerOfHanoi(n-1, start, temp, end); // temp <-> end
TowerOfHanoi(1, start, end, temp); //print now situation
TowerOfHanoi(n-1, temp, end, start); //start <-> temp
}
}