Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main(int argc, char *argv[])
- {
- ifstream odczyt("dane.txt");
- ofstream zapis("pali.txt") ;
- ofstream wynik("dane1.txt") ;
- string slowo;
- int ile=0;
- int dl;
- //cout<<slowo<<endl;
- while(!odczyt.eof())
- odczyt>>slowo;
- dl=slowo.size();
- cout<<slowo<<" "<<dl<<" ";
- bool palindrom=true;
- int i, j;
- for (i=0,j=dl-1;i<(dl/2);i++,j--)
- {
- if(slowo[i] != slowo[j])
- {
- palindrom=false;
- }
- }
- if(palindrom)
- {
- cout<<slowo<<" jest palindromem"<<endl;
- }
- else
- {
- cout<<slowo<<" nie jest palindromem"<<endl;
- }
- zapis<<"liczb palindromowych jest: "<<ile;
- cout<<ile<<endl;
- odczyt.close();
- wynik.close();
- system("PAUSE");
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement