Advertisement
Five_NT

[C++][POO] Cuvinte palindromice

Jun 5th, 2014
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string.h>
  4.  
  5. using namespace std;
  6.  
  7. ifstream f("date.in");
  8. int k;
  9. class PALINDROM
  10. {
  11.     public:
  12.         char cuv[20], aux[20];
  13.         void prelucrare(int &);
  14. };
  15.  
  16. void PALINDROM :: prelucrare(int &k)
  17. {
  18.  
  19.     k = 0;
  20.     while ( f >> cuv )
  21.     {
  22.         strcpy(aux, cuv);
  23.         strrev(aux);
  24.         if(strcmp(aux, cuv) == 0)
  25.             k ++;
  26.     }
  27. }
  28.  
  29. int main()
  30. {
  31.     PALINDROM obj;
  32.     obj.prelucrare(k);
  33.     cout << k;
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement