Advertisement
Guest User

class named "sequence"

a guest
Jan 28th, 2015
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. #pragma once
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. class sequence
  7. {
  8.  
  9. private:
  10.  
  11.     int lenghtt;
  12.     string *listbackup;
  13.  
  14. public:
  15.  
  16.     string *list;
  17.  
  18.     sequence()
  19.     {
  20.         lenghtt = 0;
  21.     }
  22.  
  23.     void Insert(string str)
  24.     {
  25.         lenghtt++;
  26.  
  27.         listbackup = list;
  28.  
  29.         list = new string[lenghtt];
  30.  
  31.         for (int i = 0; i < lenghtt - 1; i++)
  32.             list[i] = listbackup[i];
  33.  
  34.         list[lenghtt - 1] = str;
  35.  
  36.     }
  37.  
  38.     void Delete(string str)
  39.     {
  40.         for (int i = 0; i < lenghtt; i++)
  41.             if (list[i] == str)
  42.             {
  43.                 listbackup = new string[lenghtt - 1];
  44.  
  45.                 for (int i2 = 0; i2 < i; i2++)
  46.                     listbackup[i2] = list[i2];
  47.  
  48.                 for (int i2 = i; i2 < lenghtt - 1; i2++)
  49.                     listbackup[i2] = list[i2 + 1];
  50.  
  51.                 list = listbackup;
  52.             }
  53.     }
  54.  
  55.     bool Find(string str)
  56.     {
  57.         for (int i = 0; i < lenghtt; i++)
  58.             if (list[i] == str)
  59.                 return true;
  60.  
  61.         return false;
  62.     }
  63.  
  64.     void Print()
  65.     {
  66.         for (int i = 0; i < lenghtt; i++)
  67.             cout << list[i];
  68.     }
  69. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement