Advertisement
Kawalek

Klasa string

Oct 28th, 2016
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4. #include <fstream>
  5.  
  6. using namespace std;
  7.  
  8. //bool palindrom (string str)
  9. //{
  10. //    int x;
  11. //    x=str.size();
  12. //    for (int i=0; i<(x/2); i++)
  13. //    {
  14. //        if (str[i]!=str[x-i-1]) return false;
  15. //    }
  16. //}
  17.  
  18. main ()
  19. {
  20. //  int a;
  21. string str1, str2, s3,s4;
  22. //  str2= "informatyka";
  23. //  str1= "matematyka";
  24. //  str2+=str1;
  25. //  cout << str2 << endl;
  26. //  str1=str1+" to krolowa nauk";
  27. //  str1="matematyka"+"informatyka";
  28. //  cout<<str1<<endl;
  29. //  cout<<"Podaj lancuch"<<endl;
  30. //  cin>>s3;
  31. //  getline(cin,s3);
  32. //  getline(cin,s4);
  33. //  if (palindrom(s3)) cout <<"palindrom"<<endl;
  34. //  else cout <<"nie palindrom"<< endl;
  35. //  cout<<s3<<endl;
  36. //  s4=s3;
  37. //  cout<<" ma dlugosc "<< s3.size()<<endl;
  38. //  cout<< "podaj ktora litere chcesz wyswietlic ";
  39. //  cin>>a;
  40. //  cout<<s3[a]<<endl;cout << s3<< endl;
  41. //  reverse(s3.begin(),s3.end());
  42. //  cout << s3<< endl;
  43. //  cout << s4 << " "<<endl;
  44. //  if (s3==s4) cout << "to Palindrom" << endl;
  45. //  else cout << "nie jest palindromem" << endl;
  46.     ifstream plik1;
  47.     ofstream plik2;
  48.     plik1.open( "andrei.txt");
  49.     plik2.open( "wyniki.txt");
  50.     if(!plik1.good())
  51.         return false;
  52.     while (!plik1.eof())
  53.     {
  54.         plik1 >>s3>>s4;
  55.         getline(plik1,s3,' ');
  56.         getline(plik1,s4);
  57.         sort(s3.begin(),s3.end());
  58.         sort(s4.begin(),s4.end());
  59.         plik2 <<s3 <<"   "<< s4<<endl;
  60.         if (s3==s4) plik2 << "anagramy" << endl;
  61.         else plik2 << " nie anagramy" << endl;
  62.  
  63.  
  64.     }
  65.  
  66.  
  67. //    cout << s3<< endl;
  68.  
  69.     plik1.close();
  70.     plik2.close();
  71.  
  72.   return 0;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement