Advertisement
lukasd

zadanie3 zestaw14

Dec 17th, 2017
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.78 KB | None | 0 0
  1. void nowef(char **a,int n)
  2. {
  3.  
  4.     char** posortowana;
  5.     posortowana = (char**)malloc(sizeof(char*) * n);
  6.  
  7.     for (int i = 0; i < n; i++)
  8.     {
  9.         posortowana[i] = a[i];
  10.     }
  11.  
  12.     for (int j = 0; j < n; j++)
  13.     {
  14.         for (int i = 0; i < n - 1; i++)
  15.         {
  16.             if (strcmp(posortowana[i],posortowana[i+1])>0)
  17.             {
  18.                 char *b = posortowana[i];
  19.                 posortowana[i] = posortowana[i + 1];
  20.                 posortowana[i + 1] = b;
  21.             }
  22.         }
  23.     }
  24.  
  25.     for (int i = 0; i < n; i++)
  26.     {
  27.         printf("%s", posortowana[i]);
  28.     }
  29. }
  30. void kolos1()
  31. {
  32.     char** b;
  33.     b = (char**)malloc(sizeof(char*)*6);
  34.     char t1[] = "ufo";
  35.     char t2[] = "pies";
  36.     char t3[] = "kot";
  37.     char t4[] = "krowa";
  38.     char t5[] = "samochod";
  39.     char t6[] = "rower";
  40.     b[0] = t1;
  41.     b[1] = t2;
  42.     b[2] = t3;
  43.     b[3] = t4;
  44.     b[4] = t5;
  45.     b[5] = t6;
  46.    
  47.     nowef(b,6);
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement