Falu

Untitled

Jun 25th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3. #include <cctype>
  4.  
  5. using namespace std;
  6.  
  7. bool jestPalindromem( char * napis )
  8. {
  9.     bool wynik = false;
  10.     int rozmiar = strlen(napis);
  11.     char *napisS;
  12.     for(int i = 0; i < rozmiar ; i++)
  13.     {
  14.         *(napisS+i)=toupper(*(napis+i));
  15.         cout<<*(napisS+i);
  16.     }
  17.     int suma = 0;
  18.     for(int i = 0, j = rozmiar-1; i < rozmiar; i++, j--)
  19.     {
  20.         int licznik = 1;
  21.         if(*(napisS+i)==*(napisS+j) )licznik-=1;
  22.         suma+=licznik;
  23.  
  24.     }
  25. //    cout<<endl;
  26. //    for(int i = 0; i < rozmiar; i++)
  27. //    {
  28. //        cout<<*(napis+i);
  29. //    }
  30.  
  31.     if(suma == 0) wynik = true;
  32.     return wynik;
  33. }
  34. int main()
  35. {
  36.     char tab[] = "AbCbA";
  37.     cout<<jestPalindromem( tab);
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment