#include #include #include #include "defns.h" char** read_strings(int n) { char** elems = malloc(sizeof(char*)*n); for (int i=0; i < n; i++) { printf("ChaƮne.%d : ", i+1); scanf("%ms", &(elems[i])); } return elems; } void delete(char** elems, int n) { for (int i=0; i < n; i++) { free(elems[i]); } free(elems); } void print_strings(char** elems, int n) { for (int i=0; i < n; i++) { printf(" %s\n", elems[i]); } } void selsort(char** begin, char** end) { if (begin == end) return; char** mini = pos_min(begin, end); swap(begin, mini); return selsort(begin+1, end); } char** pos_min(char** begin, char** end) { char** mini = begin; for (char** ptr=begin; ptr < end; ptr++) { mini = strcmp(mini[0], ptr[0]) > 0 ? ptr : mini; } return mini; } void swap(char** a, char** b) { char* tmp = *a; *a = *b; *b = tmp; }