SHARE
TWEET

Progalap04

faragocsabi Nov 25th, 2018 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5. bool hasonlit(string a, string b, int hossz)
  6. {
  7.     bool ugyanaz;
  8.     int i = 0;
  9.     while(i < hossz && a[i] == b[i])
  10.     {
  11.         i = i + 1;
  12.     }
  13.     ugyanaz = ( i >= hossz);
  14.     return ugyanaz;
  15. }
  16.  
  17. int main()
  18. {
  19.     string DNS;
  20.     cin >> DNS;
  21.     int K = (DNS.size()/2);
  22.     int N = (DNS.size());
  23.     bool hasonlosag = false;
  24.     string egyik;
  25.     string masik;
  26.     int i,j;
  27.  
  28.     while (K >= 2 && !hasonlosag)
  29.     {
  30.         i = 0;
  31.         while (i < (N-K) && !hasonlosag)
  32.         {
  33.             egyik = DNS.substr(i,K);
  34.             j = i + K;
  35.             while (j < (N-K) && !hasonlosag)
  36.             {
  37.                 masik = DNS.substr(j, K);
  38.                 hasonlosag = hasonlit(egyik, masik, K);
  39.                 j++;
  40.  
  41.             }
  42.  
  43.             i++;
  44.         }
  45.  
  46.         K = K - 1;
  47.     }
  48.  
  49.  
  50.     if(j >= N-K && !hasonlosag)
  51.     {
  52.         cout << "" << endl;
  53.     }
  54.     else if(j < N-K && hasonlosag)
  55.     {
  56.         cout << masik << endl;
  57.     }
  58.  
  59.  
  60.     return 0;
  61. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top