Advertisement
elektryk798

LabC_Kart01A

Nov 21st, 2016
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     int i=0,czy=1,dlugosc;char tab[100]={'\0'};
  7.     do
  8.     {
  9.         czy=1;
  10.         fflush(stdin);
  11.         fgets(tab,100,stdin);
  12.         for(i=0;tab[i]!='\0';i++);
  13.         dlugosc=i-1;
  14.         //printf("dlugosc=%d\n",dlugosc);
  15.         for(i=0;i<(dlugosc/2);i++)
  16.         {
  17.             if(tab[i]!=tab[dlugosc-i-1])
  18.                 czy=0;
  19.         }
  20.         if(czy&&dlugosc>0) printf("palindrom\n"); else printf("nie palindrom\n");
  21.     }while (tab[0]!='\n');
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement