SHARE
TWEET

Untitled

a guest May 16th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. class Automat {
  6. public:
  7.     string stari;
  8.     string alfabet;
  9.     string tranzitie[6][3];
  10.     int nrLinii;
  11.     string stare_initiala;
  12.     string stare_finala;
  13.    
  14.     Automat(string stari, string alf, string tranz[][3],int nrLinii, string stare_i, string stare_f) {
  15.         this->stari = stari;
  16.         this->alfabet = alf;
  17.         this->nrLinii = nrLinii;
  18.         for (int i = 0;i < 3;i++) {
  19.             for (int j = 0;j < nrLinii;j++) {
  20.                 this->tranzitie[j][i] = tranz[j][i];
  21.             }
  22.         }
  23.         this->stare_initiala = stare_i;
  24.         this->stare_finala = stare_f;
  25.     }
  26.  
  27.     void display() {
  28.         cout << "Multimea starilor este:\n";
  29.         cout << this->stari << "\n";
  30.  
  31.         cout << "Alfabetul de intrare este:\n";
  32.         cout << this->alfabet << "\n";
  33.  
  34.         cout << "Matricea de tranzitie este:\n";
  35.         for (int i = 0;i < this->nrLinii;i++) {
  36.             for (int j = 0;j < 3;j++) {
  37.                 cout << this->tranzitie[i][j]<<" ";
  38.             }
  39.             cout << "\n";
  40.         }
  41.  
  42.         cout << "Starea initiala este:\n";
  43.         cout << this->stare_initiala << "\n";
  44.  
  45.         cout << "Starea finala este:\n";
  46.         cout << this->stare_finala << "\n";
  47.  
  48.     }
  49.  
  50. };
  51.  
  52.  
  53. int main() {
  54.  
  55.     string matrice_tranzitii[6][3] = { {"x","a","x"},
  56.     {"x","b","y"},
  57.     {"y","a","x"},
  58.     {"y","b","z"},
  59.     {"z","a","y"},
  60.     {"z","b","x"} };
  61.  
  62.     int nrLinii = 6;
  63.     Automat *a=new Automat("xyz","ab",matrice_tranzitii,nrLinii,"x","yz");
  64.     a->display();
  65.  
  66.     return 0;
  67. }
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