Advertisement
TwiNNeR

sp1lab3dat

Dec 15th, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.86 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4. #include <string.h>
  5.  
  6. int palindrom(char *a)
  7. {
  8.     int i, j=0, dolzh;
  9.     char b[50];
  10.     for(i=0;i<strlen(a);i++)
  11.     {
  12.         if(isalpha(a[i]))
  13.         {
  14.             b[j]=a[i];
  15.             j++;
  16.         }
  17.  
  18.     }
  19.     b[j]='\0';
  20.  
  21.     for(i=0;i<strlen(b)-1;i++)
  22.     {
  23.         if(toupper(b[i])!=toupper(b[strlen(b)-i-1])) return 0;
  24.     }
  25.     return 1;
  26. }
  27.  
  28. int main()
  29. {
  30.     FILE *vlez,*izlez;
  31.     if((vlez=fopen("text.txt","r"))==NULL)
  32.     {
  33.         printf("Ne go biva");
  34.         exit(-1);
  35.     }
  36.     if((izlez=fopen("print.txt","w"))==NULL)
  37.     {
  38.         printf("Ne go biva");
  39.         exit(-1);
  40.     }
  41.     char c,a[10][50];
  42.     int i=0;
  43.  
  44.     while((fscanf(vlez,"%s",&a[i][0]))!=EOF)
  45.     {
  46.  
  47.         if(palindrom(a[i])) fprintf(izlez,"%s\n");
  48.  
  49.         i++;
  50.     }
  51.  
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement