We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
int lexicographic_sort(const char* a, const char* b) {
//increasing order
return strcmp(a, b);
}
int lexicographic_sort_reverse(const char* a, const char* b) {
//decreasing order
return strcmp(b, a);
}
int sort_by_number_of_distinct_characters(const char* a, const char* b){
//increasing order
int lena = strlen(a);
int lenb = strlen(b);
int counta = 0;
int checka = 0;
int countb = 0;
int checkb = 0;
for(int i=0;i
Sorting Array of Strings
You are viewing a single comment's thread. Return to all comments →
include
include
include
int lexicographic_sort(const char* a, const char* b) { //increasing order return strcmp(a, b); }
int lexicographic_sort_reverse(const char* a, const char* b) { //decreasing order return strcmp(b, a); }
int sort_by_number_of_distinct_characters(const char* a, const char* b){ //increasing order int lena = strlen(a); int lenb = strlen(b); int counta = 0; int checka = 0; int countb = 0; int checkb = 0; for(int i=0;i
void string_sort(char** arr,const int len,int (cmp_func)(const char a, const char* b)){ for(int i=0;i0){ char *temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } } } }
int main() { int n; scanf("%d", &n);
}