///by 자바하는놈 #include<stdio.h> #include<string.h> int bubble_sort_char(char str[], size_t size) { if(size <= 1) { return 0; } unsigned int pos; int finished; char temp; pos = 0; while(1) { finished = 1; for(; pos < size-1; pos++) { if(str[pos] > str[pos+1]) { finished = 0; temp = str[pos]; str[pos] = str[pos+1]; str[pos+1] = temp; } } if(finished) { break; } pos++; } printf("%s\n", str); return 0; } int main() { char str[] = "unsorted"; bubble_sort_char(str, strlen(str)); printf("%s\n", str); getchar(); }
Copyrights © - Joinc, All Rights Reserved. Inherited From - Yundream Rebranded By - Joonphil
문제
Recent Posts
Archive Posts
Tags