Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- #include <cctype>
- using namespace std;
- bool jestPalindromem( char * napis )
- {
- bool wynik = false;
- int rozmiar = strlen(napis);
- char *napisS;
- for(int i = 0; i < rozmiar ; i++)
- {
- *(napisS+i)=toupper(*(napis+i));
- cout<<*(napisS+i);
- }
- int suma = 0;
- for(int i = 0, j = rozmiar-1; i < rozmiar; i++, j--)
- {
- int licznik = 1;
- if(*(napisS+i)==*(napisS+j) )licznik-=1;
- suma+=licznik;
- }
- // cout<<endl;
- // for(int i = 0; i < rozmiar; i++)
- // {
- // cout<<*(napis+i);
- // }
- if(suma == 0) wynik = true;
- return wynik;
- }
- int main()
- {
- char tab[] = "AbCbA";
- cout<<jestPalindromem( tab);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment