ivana_andreevska

Untitled

May 19th, 2021
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 KB | None | 0 0
  1. Да се напише функција која ќе проверува дали дадена текстуална низа е палиндром
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <ctype.h>
  6. #define MAX 101
  7.  
  8. int isPalindrom(char s1[100])
  9. {
  10.     int i;
  11.     int n=strlen(s1);
  12.     for(i=0;i<strlen(s1);i++)
  13.  
  14.         if(s1[i]!=s1[n-i-1])
  15.             return 0;
  16.  
  17.     return 1;
  18.  
  19. }
  20.  
  21. int main()
  22. {
  23.     char string[MAX];
  24.     gets(string);
  25.  
  26.     printf("%d",isPalindrom(string));
  27.  
  28.     return 0;
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment