Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Pavel Trostianko. Lygiagretusis Tiuringas.
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <conio.h>
- using namespace std;
- struct tiuring //kintamu ir funkciju sarasas
- {
- bool check;
- int len = 0, sk, nmbr;
- char second[1000], third[1000], four[1000];
- string first[1000], five[1000], poz, tiur;
- void Reading()
- {
- string selecting;
- cout << nmbr << ".txt adress: ";
- start:
- getline (cin, selecting);
- ifstream fil(selecting.c_str());
- if(fil.fail())
- {
- cout << "File Name Error!" << endl;
- goto start;
- }
- fil >> sk;
- fil >> tiur;
- while (fil >> first[len] >> second[len] >> third[len] >> four[len] >> five[len])
- {
- len++;
- }
- fil.close();
- }
- void Showing()
- {
- cout << endl;
- cout << "File: " << nmbr << endl;
- cout << tiur << endl;
- cout << endl;
- for(int i=0;i<len;i++)
- {
- cout << first[i] << " " << second[i] << " " << third[i] << " " << four[i] << " " << five[i] << endl;
- }
- }
- void Process()
- {
- cout << "File number: " << nmbr << " ";
- if(check==true)
- {
- poz = first[0];
- }
- string er;
- for(int i=0;i<len;i++)
- if(poz == first[i])
- {
- if(second[i] == tiur[sk+1])
- {
- tiur[sk+1]= third[i];
- if(four[i]=='r' || four[i]=='R')
- {
- sk++;
- }
- else
- {
- sk--;
- }
- if(sk < 0)
- {
- sk = tiur.length();
- }
- if(sk > tiur.length())
- {
- sk=0;
- }
- poz = five[i];
- }
- }
- if(er != tiur) cout << tiur << endl;
- er = tiur;
- }
- };
- int main()
- {
- bool checking = false;
- tiuring onet, twot, threet, fourt;
- onet.nmbr = 1;
- twot.nmbr = 2;
- threet.nmbr = 3;
- fourt.nmbr = 4;
- // Reading our line
- onet.Reading();
- twot.Reading();
- threet.Reading();
- fourt.Reading();
- // Showing our line
- onet.Showing();
- twot.Showing();
- threet.Showing();
- fourt.Showing();
- // Checking our line
- onet.check = true;
- twot.check = true;
- threet.check = true;
- fourt.check = true;
- if(getch()=='t')
- {
- checking = true;
- }
- while(true)
- {
- onet.Process();
- onet.check = false;
- twot.Process();
- twot.check = false;
- threet.Process();
- threet.check = false;
- fourt.Process();
- fourt.check = false;
- if(checking == true)
- {
- getch();
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement