Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <vector>
- using namespace std;
- class uchev_plan {
- public:
- string name_index;
- int num_house;
- };
- class group {
- public:
- int count;
- string name_group;
- string potok;
- int num_potok;
- bool occupated;
- vector<uchev_plan> kart;
- };
- class auditoria {
- public:
- int count;
- string name;
- bool employment; // 1 - занята, 0 - свободна
- bool vid_audirorii; // 1 - лекционная, 0 - обычная
- vector<string> vid;
- };
- void Load_files(vector<group>& parent1, vector<auditoria>& parent2) {
- ifstream loader;
- group gr;
- uchev_plan up;
- auditoria aud;
- vector<uchev_plan> temp;
- string path = "group.txt";
- string path1 = "plan.txt";;
- bool flag = true;
- loader.open(path);
- if (!loader) {
- cout << "Файл "<<path<<" не открылся, убедитесь, что файл лежит в папке с программой и перезапустите её\n";
- }
- string name1;
- string name2;
- string buf;
- int buff;
- while (!loader.eof()) {
- loader >> buff;
- gr.count = buff;
- loader >> name1;
- gr.name_group = name1;
- loader >> buf;
- gr.potok = buf;
- loader >> buff;
- gr.num_potok = buff;
- loader >> buff;
- gr.occupated = buff;
- ifstream plan;
- plan.open(path1);
- while (!plan.eof()) {
- if (flag == true) {
- plan >> name2;
- flag = false;
- }
- plan >> buf;
- if (buf == "end") {
- flag = true;
- if (name2 == name1) {
- gr.kart = temp;
- temp.clear();
- }
- else {
- temp.clear();
- }
- continue;
- }
- else {
- up.name_index = buf;
- plan >> buff;
- up.num_house = buff;
- temp.push_back(up);
- }
- }
- plan.close();
- parent1.push_back(gr);
- }
- loader.close();
- path = "auditoria.txt";
- loader.open(path);
- if (!loader) {
- cout << "Файл " << path << " не открылся, убедитесь, что файл лежит в папке с программой и перезапустите её\n";
- }
- while (!loader.eof()) {
- loader >> buff;
- aud.count = buff;
- loader >> buf;
- aud.name = buf;
- loader >> buff;
- aud.employment = buff;
- loader >> buff;
- aud.vid_audirorii = buff;
- parent2.push_back(aud);
- }
- loader.close();
- }
- void print(vector<auditoria>& a)
- {
- cout << "Auds: \n";
- for (vector<auditoria>::iterator it = a.begin(); it != a.end(); ++it) {
- cout << it->count << "\t" << it->name << "\t" << it->employment << "\t" << it->vid_audirorii << endl;
- }
- }
- void print(vector<group>& a) // здесь можно увидеть как вызывается учебный план
- {
- cout << "Groups: \n";
- for (vector<group>::iterator it = a.begin(); it != a.end(); ++it) {
- cout << it->count << "\t" << it->name_group << "\t" << it->potok << "\t" << it->num_potok << "\t" << it->occupated << endl;
- vector<uchev_plan> up;
- up = it->kart;
- cout << endl<<"Ucheb_plan: \n";
- for (vector<uchev_plan>::iterator it = up.begin(); it != up.end(); ++it) {
- cout << it->name_index << "\t" << it->num_house << endl;
- }
- cout << endl;
- up.clear();
- }
- }
- int main()
- {
- setlocale(LC_ALL, "rus");
- vector<group> groups;
- vector<auditoria> audiences;
- Load_files(groups, audiences);
- print(groups);
- print(audiences);
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement