diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-07-21 15:26:32 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-07-21 15:26:32 +0200 |
| commit | 23ad79e8b41c25bb4992d103d29a17612a52e351 (patch) | |
| tree | 9de3cde07cc38e59f08885171e9f99eeab8ab71b /c11/main.c | |
| parent | 8b6e91bdb56bc01a588718472546f2a88e750b48 (diff) | |
| download | piscine-23ad79e8b41c25bb4992d103d29a17612a52e351.tar.gz piscine-23ad79e8b41c25bb4992d103d29a17612a52e351.tar.bz2 piscine-23ad79e8b41c25bb4992d103d29a17612a52e351.zip | |
c10 done, c11 on going, rush02 probably finished, bsq start
Diffstat (limited to 'c11/main.c')
| -rw-r--r-- | c11/main.c | 33 |
1 files changed, 25 insertions, 8 deletions
@@ -13,6 +13,7 @@ void f_fe(int x); int f_ma(int x); int f_len(char *x); int f_cou(char *x); +int f_sor_dsc(int x, int y); int f_sor(int x, int y); int f_lensort(char *a, char *b); @@ -43,21 +44,30 @@ int main() printf("\n------------------------\n"); int sorted[10] = {1, 2, 3, 4, 5, 5, 6}; - printf("sorted %d", ft_is_sort(sorted, 6, &f_sor)); + printf("sorted asc %d\n", ft_is_sort(sorted, 6, &f_sor)); + int sorted_dsc[10] = {7, 6, 4, 1, 0, -10}; + printf("sorted dsc %d", ft_is_sort(sorted_dsc, 6, &f_sor_dsc)); + printf("\n------------------------\n"); - char **a = malloc(sizeof(char*) * 5); + char **a = malloc(sizeof(char*) * 8); a[0] = malloc(sizeof(char) * 32); a[1] = malloc(sizeof(char) * 32); a[2] = malloc(sizeof(char) * 32); a[3] = malloc(sizeof(char) * 32); - strcpy(a[0], "bonjour"); - strcpy(a[1], "je"); - strcpy(a[2], "suis"); - strcpy(a[3], "charles"); - a[4] = NULL; + a[4] = malloc(sizeof(char) * 32); + a[5] = malloc(sizeof(char) * 32); + a[6] = malloc(sizeof(char) * 32); + strcpy(a[0], "dQ4ilBI6T$"); + strcpy(a[1], "16Tz2R$"); + strcpy(a[2], "4zQplLtBc$"); + strcpy(a[3], "7$"); + strcpy(a[4], "7hE84k$"); + strcpy(a[5], "841SqkO$"); + strcpy(a[6], "ItM$"); + a[7] = NULL; ft_sort_string_tab(a); - for (int i = 0; i < 5; i++) + for (int i = 0; i < 7; i++) printf("%s\n", a[i]); printf("\n------------------------\n"); @@ -102,6 +112,13 @@ int f_cou(char *x) return counter > 2; } +int f_sor_dsc(int x, int y) +{ + if (x == y) + return (0); + return x > y ? -1 : 1; +} + int f_sor(int x, int y) { if (x == y) |
