Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <map>
- using namespace std;
- struct vertex
- {
- bool isterminal = false;
- //std::vector<struct adj_vertex> adj_list;
- map<char,int> adj_list;
- int list_size = 0;
- int number_vertex;
- };
- struct vertex_2
- {
- int u;
- int v;
- bool isterminal = false;
- bool isvisited = false;
- };
- struct adj_vertex
- {
- int number_vertex;
- char symbol;
- };
- class Decart_Graph
- {
- int count_numbers;
- public:
- Decart_Graph();
- void Initialize();
- bool Contains(int number) const;
- class Graph
- {
- struct vertex* graph;
- int count_edges;
- int count_vertex;
- public:
- explicit Graph(int count_vertex, int* terminals, int k);
- void addEdge(int i, int j, char symbol);
- void display();
- };
- Decart_Graph::Graph::Graph(int count_vertex, int* terminals, int k)
- {
- graph = new vertex[count_vertex];
- this->count_edges = 0;
- this->count_vertex = count_vertex;
- for (int i = 0; i < k; ++i)
- {
- graph[terminals[i]].isterminal = true;
- }
- }
- void Decart_Graph::Graph::addEdge(int i, int j, char symbol)
- {
- graph[i].adj_list[symbol] = j;
- graph[i].list_size++;
- }
- void Decart_Graph::Graph::display()
- {
- cout << "\n print:" << endl;
- for (int i = 0; i < this->count_vertex; i++)
- {
- cout << "vertex: " << i << " ";
- if (graph[i].isterminal) cout << "isterminal" << " ";
- int size = graph[i].adj_list.size();
- cout << "adj_vertexes: ";
- for(const auto& elem : graph[i].adj_list)
- {
- std::cout << "(" << elem.first << "," << elem.second << ")" << "; ";
- }
- cout << endl;
- }
- }
- Graph Decart_Graph::ReadDFA(int n, int k, int l)
- {
- int u,v;
- char c;
- int t[k];
- for (int i = 0; i < k; ++i)
- cin >> t[i];
- Graph DFA(n,t,k);
- for (int i = 0; i < n*l; ++i)
- {
- cin >> u >> c >> v;
- DFA.addEdge(u,v,c);
- }
- return DFA;
- }
- void Decart_Graph::Initialize()
- {
- //n — колво состояний. k — колво терминальных состояний. l — колво букв в алфавите.
- int n1, k1, l1;
- int n2, k2, l2;
- cin >> n1 >> k1 >> l1;
- Graph DFA1 = ReadDFA(n1, k1, l1);
- cin >> n2 >> k2 >> l2;
- Graph DFA2 = ReadDFA(n2, k2, l2);
- DFA1.display();
- DFA2.display();
- /*
- for (int i = 0; i < n1; ++i)
- {
- for (int j = 0; j < n2; ++j)
- {
- }
- }
- */
- }
- int main()
- {
- cout << 5;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment