Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- void palindrom (char slowo[50], char odwrocone[50])
- {
- printf("Wpisz slowo, zeby sprawdzic czy jest palindromem: \n");
- scanf("%[^\n]s", slowo); //[^n] sprawia, ze wczytuje cale zdanie, nie tylko 1 slowo
- strcpy(odwrocone, slowo); //kopiuje drugi element do pierwszego
- strrev(odwrocone); //odwraca element - zapisuje go od tylu
- if (strcmp(slowo, odwrocone) == 0) //strcmp - porownuje 2 lancuchy znakow, jesli jest identyczna zwraca 0
- printf("To slowo jest palindromem. \n");
- else
- printf("To slowo NIE jest palindromem. \n");
- return 0;
- }
- int main()
- {
- char a[50], b[50];
- palindrom(a, b);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement