Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #define strcmpi strcasecmp
  4.  
  5. int main () {
  6. char names[5][255] = {
  7. "asd", "ASD", "qwe", "aasd", "qwcf"
  8. };
  9.  
  10. // bubble sort
  11. int i = 0;
  12.  
  13. do {
  14. int j = 0;
  15. do {
  16. if (strcmpi(names[i], names[j]) < 0) {
  17. char name[255];
  18.  
  19. strcpy(name, names[i]);
  20. strcpy(names[i], names[j]);
  21. strcpy(names[j], name);
  22. }
  23.  
  24. ++j;
  25. } while (j < 5);
  26. ++i;
  27. } while (i < 5);
  28.  
  29. for (int i = 0 ; i < 5 ; ++i) {
  30. printf("%s ", names[i]);
  31. }
  32.  
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement