버블정렬 (2) 썸네일형 리스트형 문자열 버블정렬~ #include #include #include #define SIZE 1024 void bubbleSort(char *str); void swap(char *base, char *target); int getSize(char *str); void bubbleSort(char *str){ int i, j; for(i = 0 ; i < getSize(str) ; i++) { for (j = 0 ; j < getSize(str) ; j++) { if (str[i] < str[j]) swap(&str[i],&str[j]); } } } int getSize(char *str){ int size = 0; int i; for(i = 0;;i++){ if(str[i] == '\0') break; else size++.. 배열과 포인터를 활용한 Bubble Sort 알고리즘 #include #define MAX_SIZE 100 void bubbleSort(int array[], int size); void swap(int* base, int* target); void displayArray(int array[], int size); void bubbleSort(int array[], int size){ int i, j; for(i = 0; i < size ; i++) { for(j = 0; j < i ; j++) if (array[i] < array[j]) swap(&array[i], &array[j]); } displayArray(array, size); } void displayArray(int array[], int size){ int i; for(i = 0; i < .. 이전 1 다음