Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
- #include <string.h>
- int palindrom(char *a)
- {
- int i, j=0, dolzh;
- char b[50];
- for(i=0;i<strlen(a);i++)
- {
- if(isalpha(a[i]))
- {
- b[j]=a[i];
- j++;
- }
- }
- b[j]='\0';
- for(i=0;i<strlen(b)-1;i++)
- {
- if(toupper(b[i])!=toupper(b[strlen(b)-i-1])) return 0;
- }
- return 1;
- }
- int main()
- {
- FILE *vlez,*izlez;
- if((vlez=fopen("text.txt","r"))==NULL)
- {
- printf("Ne go biva");
- exit(-1);
- }
- if((izlez=fopen("print.txt","w"))==NULL)
- {
- printf("Ne go biva");
- exit(-1);
- }
- char c,a[10][50];
- int i=0;
- while((fscanf(vlez,"%s",&a[i][0]))!=EOF)
- {
- if(palindrom(a[i])) fprintf(izlez,"%s\n");
- i++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement