Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- int main(int argc, const char * argv[]) {
- if(argc < 3) {
- return 0;
- }
- FILE *in = fopen(argv[1], "r");
- FILE *out = fopen(argv[2], "w");
- char zbor[1000];
- int brojac = 0;
- while(fscanf(in, "%s", zbor)) {
- if(zbor[strlen(zbor) - 1] == '.' || zbor[strlen(zbor - 1)] == ',') {
- int dali_e_palindrom = 1;
- int i = 0;
- int j = strlen(zbor) - 2;
- while(i < j) {
- if(zbor[i] == zbor[j]) {
- i++;
- j--;
- }
- else {
- dali_e_palindrom = 0;
- break;
- }
- }
- if(dali_e_palindrom) {
- for(int k = 0; k < strlen(zbor) - 1; k++) {
- fprintf(out, "%c", zbor[k]);
- }
- fprintf(out, "\n");
- brojac++;
- }
- }
- }
- fprintf(out, "%d\n", brojac);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement