Advertisement
Falu

Untitled

Jun 25th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. bool jestPalindromem(char * napis)
  2. {
  3.     int dlugosc=0;
  4.     while (*napis != '\0')
  5.     {
  6.         dlugosc++;
  7.  
  8.         *napis = tolower(*napis);
  9.         napis++;
  10.     }
  11.     napis -= dlugosc;
  12.  
  13.     for (int poczatek = 0, koniec = dlugosc - 1; poczatek < koniec; poczatek++, koniec--)
  14.     {
  15.  
  16.         while (*(napis + poczatek) == ' ') poczatek++;
  17.         while (*(napis + koniec) == ' ') koniec--;
  18.         if (*(napis + poczatek) != *(napis + koniec)) return false;
  19.  
  20.     }
  21.     return true;
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement