I'm trying to implement a sorting function which would sort the characters from an array. Can someone tell why it's not working?
int main() { char tab[] = {'e', 'b', 'd', 'z', 'a', 't', '\0'}; char tab2[7] = {0}; int i = 0, j = 0, k = 0; while (tab[i] != '\0') { for (j = 0; tab[j] != '\0'; j++) { if (tab[i] > tab2[j]) { tab2[k] = tab[j]; k++; } } k=0; i++; } printf("%s\n", tab2); return 0; } https://stackoverflow.com/questions/67051301/implementing-bubble-sort-in-c April 12, 2021 at 08:14AM
没有评论:
发表评论