Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. int main(int argc, char *argv[])
  8. {
  9. ifstream odczyt("dane.txt");
  10. ofstream zapis("pali.txt") ;
  11. ofstream wynik("dane1.txt") ;
  12. string slowo;
  13. int ile=0;
  14. int dl;
  15.  
  16.  
  17. //cout<<slowo<<endl;
  18.  
  19. while(!odczyt.eof())
  20.  
  21. odczyt>>slowo;
  22. dl=slowo.size();
  23. cout<<slowo<<" "<<dl<<" ";
  24. bool palindrom=true;
  25. int i, j;
  26. for (i=0,j=dl-1;i<(dl/2);i++,j--)
  27. {
  28. if(slowo[i] != slowo[j])
  29. {
  30. palindrom=false;
  31. }
  32. }
  33. if(palindrom)
  34. {
  35. cout<<slowo<<" jest palindromem"<<endl;
  36. }
  37. else
  38. {
  39. cout<<slowo<<" nie jest palindromem"<<endl;
  40. }
  41.  
  42. zapis<<"liczb palindromowych jest: "<<ile;
  43. cout<<ile<<endl;
  44. odczyt.close();
  45. wynik.close();
  46.  
  47.  
  48.  
  49. system("PAUSE");
  50. return EXIT_SUCCESS;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement