Paste Search Dynamic
Recent pastes
loadingLyrics
  1. #include<iostream>
  2. #include<vector>
  3. #include<algorithm>
  4.  
  5. using namespace std;
  6.  
  7. void loadingLyrics(vector<string> &lyrics)
  8. {
  9.     string word;
  10.     char znak;
  11.     while(cin >> word)
  12.     {
  13.         lyrics.push_back(word);
  14.         znak = getchar();
  15.         if (znak == 32)
  16.         {
  17.             continue;
  18.         }
  19.         else if ( znak == 13);
  20.         return;
  21.     }
  22. }
  23.  
  24. void loadingForgottenWords(vector<string> &lyrics, vector<string> &forgottenWords)
  25. {
  26.     string word;
  27.     char znak;
  28.  
  29.     cin >> word;
  30.     for (int i=0; i<lyrics.size(); i++)
  31.     {
  32.         if (((lyrics[i]) == word) && (i != (lyrics.size()-1) ) )
  33.         {
  34.             cin >> word;
  35.         }
  36.         else if (lyrics[i]!= word)
  37.         {
  38.             forgottenWords.push_back(lyrics[i]);
  39.         }
  40.     }
  41. }
  42.  
  43. void displayVector(vector<string> &forgottenWords)
  44. {
  45.     for (int i=0; i<forgottenWords.size(); i++)
  46.     {
  47.         cout << forgottenWords[i] << endl;
  48.     }
  49. }
  50.  
  51. int main()
  52. {
  53.     vector<string> lyrics;
  54.     vector<string> forgottenWords;
  55.  
  56.     loadingLyrics(lyrics);
  57.  
  58.     loadingForgottenWords(lyrics, forgottenWords);
  59.  
  60.     sort(forgottenWords.begin(), forgottenWords.end());
  61.  
  62.     cout << forgottenWords.size() << endl;
  63.     displayVector(forgottenWords);
  64.  
  65.     return 0;
  66. }
  67.  
Parsed in 0.005 seconds