Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void process_file(map<int, vector<Road*>> & ver_roads, map<int, vector<Road*>> & hor_roads, int & AVTO)
- {
- ifstream fin;
- ofstream fout;
- int N, M;
- int ALL;
- vector<Event*> events;
- map<int, User*> last_pos;
- fin.open("input.txt");
- fout.open("output.txt");
- fin >> N; fin >> M; fin >> AVTO; fin >> ALL;
- vector<vector<roads_speeds>> speeds; // массив со всеми скоростями, которые фиксировались на этой дороге.
- speeds.resize(N + M);
- for (int i = 0; i < N; ++i)
- read_ver_roads(ver_roads, fin, i);
- for (int i = 0 + N; i < M + N; ++i)
- read_hor_roads(hor_roads, fin, i);
- while (!fin.eof())
- process_message(ver_roads, hor_roads, fin, fout, events, AVTO, last_pos, speeds);
- fin.close();
- fout.close();
- }
- void process_message(map<int, vector<Road*>> & ver_roads, map<int, vector<Road*>> & hor_roads, ifstream & fin, ofstream & fout, vector<Event*> & events, int & AVTO, map<int, User*> & last_pos, vector<vector<roads_speeds>> & speeds)
- {
- void (*answer_request[4])(ifstream & fin, ofstream & fout, map<int, vector<Road*>> & ver_roads, map<int, vector<Road*>> & hor_roads, vector<Event*> & events, vector<vector<roads_speeds>> & speeds, int & time_num) =
- { f0, f1, f2, f3 };
- string time_str, message_type;
- int time_num;
- fin >> time_str;
- fin >> message_type;
- //printf("%s || ", time_str.c_str());
- const char* s1 = time_str.substr(0, 2).c_str();
- int hour = atoi(s1);
- //printf("%s - %d || ", s1, hour);
- const char* s2 = time_str.substr(3, 2).c_str();
- int min = atoi(s2);
- //printf("%s - %d\n", s2, min);
- time_num = hour * 60 + min;
- if (message_type == "OBJECT")
- {
- int id, x, y, speed;
- fin >> id; fin >> x; fin >> y; fin >> speed;
- roads_object object = roads_object(time_str, time_num, id, x, y, speed);
- check_offense(ver_roads, hor_roads, events, AVTO, object, last_pos, speeds);
- }
- else // REQUEST
- {
- int type;
- fin >> type;
- answer_request[type - 1](fin, fout, ver_roads, hor_roads, events, speeds, time_num);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement