Advertisement
rootuss

PATRYK PALINDROM

Dec 8th, 2017
422
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstdlib>
  4. #include <string>
  5. #include <conio.h>
  6.  
  7. using namespace std;
  8.  
  9. string imie, nazwisko;
  10. int nr_tel;
  11.  
  12. int main()
  13. {
  14.     fstream d,w;
  15.  
  16.     d.open("dane.txt",ios::in);
  17.     w.open("wyniki.txt",ios::out);
  18.  
  19.     if(d.good()==false)
  20.     {
  21.         cout<<"popsules cos moze utworz d zal mi cie"<<endl;
  22.         exit(0);
  23.     }
  24.  
  25.     string l;
  26.     int dl=0;
  27.     int k=0;
  28.  
  29.     while(getline(d,l)) {
  30.         dl=l.length();
  31.         k=0;
  32.         for (int i=0;i<dl/2;i++) if(l[i]!=l[dl-i-1]) k++;
  33.  
  34.         if(k!=0) w<<l<<" nie jest palindromem"<<endl;
  35.         else w<<l<<" jest palindromem"<<endl;
  36.  
  37.     }
  38.  
  39.  
  40.     d.close();
  41.     w.close();
  42.  
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement