#include <iostream>
#include <cstring>
#include <algorithm>
void sort(char **strings, int size);
int main() {
const int DAYS = 7;
char *arrptrs[DAYS] = {"Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday",
"Friday", "Saturday"
};
sort(arrptrs, DAYS);
for (auto &arrptr : arrptrs)
std::cout << arrptr << " ";
std::cout << std::endl;
return 0;
}
void sort(char **strings, int size) {
for (int i = 0; i < size - 1; ++i) {
for (int j = i + 1; j < size; ++j) {
if (std::strcmp(strings[i], strings[j]) > 0) {
std::swap(strings[i], strings[j]);
}
}
}
}
Comments
Leave a comment