Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include"pch.h"
- #include <iostream>
- #include <string>
- #include <list>
- #include <algorithm>
- #include <fstream>
- using std::string;
- using namespace std;
- int main()
- {
- char Z[10];
- char N[10];
- char e = { 'e' };
- int qcount = 0;
- //Происходит задание грамматики из файла. Размер алфавитов задается фиксированный.
- string P[10][10] = { " " };
- int inprule[10] = { 0 };
- string Pn[10][50] = { " " };
- string M[100] = { " " };
- int n = 0;
- ifstream input("start.txt");
- string buf;
- getline(input, buf);
- for (int i = 0; i < buf.length(); ++i)
- {
- Z[i] = buf[i];
- }
- cout << endl << buf << endl;
- getline(input, buf);
- for (int i = 0; i < buf.length(); ++i)
- {
- N[i] = buf[i];
- n++;
- }
- cout << endl << n << endl;
- cout << endl << buf << endl;
- while (!input.eof())
- {
- getline(input, buf);
- cout << buf << endl;
- for (int i = 0; i < n; ++i)
- {
- if (buf[0] == N[i])
- {
- buf.erase(0, 1);
- P[i][inprule[i]] = "";
- P[i][inprule[i]] += buf;
- inprule[i]++;
- break;
- }
- }
- }
- cout << endl;
- //Выводим заданную грамматику G для удобства наблюдения результатов
- cout << "Gram G" << endl;
- for (int i = 0; i < n; ++i)
- {
- cout << N[i] << " ";
- for (int j = 0; j < 10; ++j)
- {
- if (P[i][j] != " ") cout << P[i][j] << " ";
- }
- cout << endl;
- }
- cout << "------------------------------" << endl;
- for (int i = 0; i < n; ++i)
- {
- cout << M[i] << "\t";
- }
- int ukaz = n;
- int ukazstart = n;
- cout << endl;
- for (int i = 0; i < n; ++i)
- {
- }
- //Выводим грамматику G' как результат работы программы
- cout << "Gramm G'" << endl;
- for (int i = 0; i < n; ++i)
- {
- cout << N[i] << "\t";
- for (int j = 0; j < inprule[i]; ++j)
- {
- if (P[i][j] != " ") cout << P[i][j] << " ";
- }
- cout << endl;
- }
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment