Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- FILE *input, *output;
- char word[50], *rword, save;
- int s = 0,size = 0, e=1;
- input = fopen("input.txt", "r");
- if (input == NULL)
- {
- printf("File 'input.txt' does not exist");
- fclose(input);
- }
- else
- {
- while((fscanf(input, "%c", &word)!=EOF))
- {
- if(!input) break;
- size+=1;
- }
- }
- if (size>=50)
- {
- printf("Invalid input\n");
- return 0;
- }
- if (size%2==1)
- {
- printf("Invalid input\n");
- return 0;
- }
- else
- for (int i=0; i<size-2/2; i++)
- if(word[i]!=word[size-i-1])
- e=e-1;
- printf("e = %d\n",e);
- int j=size;
- if (e==0)
- {
- for (int i=0;i<size/2;i++)
- {
- word[j+1]=*rword+i;
- j=j-1;
- }
- }
- else
- {
- printf("Invalid input\n");
- return 0;
- }
- for (int i=0;i<size;i++)
- printf("%c",word[i]);
- output = fopen("output.txt", "w");
- if (output == NULL)
- {
- printf("File 'output.txt' does not exist");
- fclose(output);
- }
- else
- {
- for (int i=0;i<size;i++)
- fprintf(output,"%c",word[i]);
- }
- fclose(output);
- fclose(input);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement