Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.09 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int liczbaLinii;
  9.     cout << "Podaj liczbe linii" << endl;
  10.     cin >> liczbaLinii;
  11.     string wzorzec, linia;
  12.  
  13.     cin >> wzorzec;
  14.  
  15.     for(int i = 0; i < wzorzec.size(); ++i)
  16.     {
  17.         wzorzec[i] = tolower(wzorzec[i]);
  18.     }
  19.  
  20.     getline(std::cin, linia);
  21.  
  22.     for(int i = 0; i < liczbaLinii; ++i)
  23.     {
  24.         getline(std::cin, linia);
  25.  
  26.         cout << linia << endl;
  27.  
  28.         for(int x = 0; x < linia.size(); ++x)
  29.         {
  30.             linia[x] = tolower(linia[x]);
  31.         }
  32.  
  33.         size_t found = linia.find(wzorzec);
  34.         size_t lastFound = 0;
  35.  
  36.         while(found != string::npos)
  37.         {
  38.             for(int x = 0; x < (found - lastFound); ++x)
  39.             {
  40.                 cout << " ";
  41.             }
  42.  
  43.             for(int x = 0; x < wzorzec.size(); ++x)
  44.             {
  45.                 cout << "-";
  46.             }
  47.  
  48.             lastFound = found + wzorzec.size();
  49.             found = linia.find(wzorzec, found+wzorzec.size());
  50.         }
  51.  
  52.         cout << endl;
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement