Advertisement
Guest User

Untitled

a guest
May 4th, 2022
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1. int* dlugosci_slow(int szerokosc, char* tab)
  2. {
  3.     int ilosc_slow = 0;
  4.     int i = 0;
  5.     int max = 0;
  6.     while (tab[i] != NULL)
  7.     {
  8.         if (tab[i] == ' ')
  9.             ilosc_slow++;
  10.         i++;
  11.     }
  12.     ilosc_slow++;
  13.  
  14.     int* tab_pom = (int*)malloc(ilosc_slow * sizeof(int));
  15.  
  16.     i = 0;
  17.     int j = 0;
  18.     while (tab[i] != NULL)
  19.     {
  20.         if (tab[i] != ' ')
  21.             max++;
  22.         else
  23.         {
  24.             tab_pom[j] = max;
  25.             j++;
  26.             max = 0;
  27.         }
  28.         i++;
  29.     }
  30. return tab_pom;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement