Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <string>
- #include <fstream>
- #include <string.h>
- #include <iostream>
- using namespace std;
- //////// Przykladowy input
- /*
- ada
- dada
- kur ruk
- sedes
- piernik
- kolendra
- kur ruk
- */
- ///////////////////////////
- /* output ktory mi generuje jest bledny
- 1
- 0
- 1
- 1
- 0
- 0
- 0
- */
- bool CzyPalimdrom(char *slowo)
- {
- int i = 0;
- int j = 0;
- bool wynik = true;
- string s = string(slowo);
- int n = s.length() - 2;
- string sk;
- for (i = 0, j = s.length() - 2; i < j; i++, j--)
- if (s[i] != s[j]) break;
- if (i < j) wynik = false;
- return wynik;
- }
- int main()
- {
- FILE *in; // PLIK z ktoreg pobieramy dane
- in = fopen("in.txt", "a+");
- FILE *out; // Plik do ktrego zapisujemy dane
- out = fopen("out.txt", "w");
- char buff[50];
- while( feof(in) == 0)
- {
- fgets(buff, sizeof(buff), in);
- if (CzyPalimdrom(buff) == true)
- fprintf(out, "1 \n");
- else
- fprintf(out, "0 \n");
- }
- fclose(in);
- fclose(out);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement