Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.56 KB | None | 0 0
  1. #include <map>
  2. #include <iostream>
  3. #include <fstream>
  4. #include <utility>
  5. #include <vector>
  6. #include <algorithm>    // std::random_shuffle
  7. #include <ctime>        // std::time
  8. #include <cstdlib>      // std::rand, std::srand
  9. #include <random>
  10.  
  11. using namespace std;
  12.  
  13. struct Task {
  14.     Task(string url, string type) {
  15.         this->url = std::move(url);
  16.         this->type = std::move(type);
  17.     }
  18.     string url;
  19.     string type;
  20. };
  21.  
  22. struct BinLearn {
  23.     BinLearn(string url, string signRus, string res, string hint) {
  24.         this->url = std::move(url);
  25.         this->signRus = std::move(signRus);
  26.         this->hint = std::move(hint);
  27.         this->res = std::move(res);
  28.     }
  29.     string url;
  30.     string signRus;
  31.     string res;
  32.     string hint;
  33. };
  34.  
  35. int main() {
  36.     srand(time(nullptr));
  37.     freopen("Road_Signs/Экзамен-Table 1.tsv", "r", stdin); // Боевые задания-Table 1.tsv Боевые задания
  38.     freopen("TASKShw5ExamBin.tsv", "w", stdout);
  39.     string url, type;
  40.     vector<Task> data;
  41.     cout << "INPUT:image\tINPUT:sign_name\tGOLDEN:result\n"; //     HINT:text
  42.     while (cin >> url >> type) {
  43. //        cout << url << '\t' << type << endl;
  44.         data.emplace_back(url, type);
  45.     }
  46.     vector<BinLearn> dataBin;
  47.     vector<string> curSign;
  48.     vector<string> curSignRus;
  49.     curSign.emplace_back("no_stop");
  50.     curSign.emplace_back("give_way");
  51.     curSign.emplace_back("bus_stop");
  52.     curSign.emplace_back("pedestrian");
  53.     curSign.emplace_back("main_road");
  54.  
  55.     curSignRus.emplace_back("Остановка запрещена");
  56.     curSignRus.emplace_back("Уступи дорогу");
  57.     curSignRus.emplace_back("Остановка общественного транспорта");
  58.     curSignRus.emplace_back("Пешеходный переход");
  59.     curSignRus.emplace_back("Главная дорога");
  60.  
  61.     std::random_device rd;
  62.     std::mt19937 g(rd());
  63.     std::shuffle(begin(data), end(data), g);
  64.     string typeRus;
  65.     for (size_t i = 0; i < data.size(); ++i) {
  66.         for (size_t j = 0; j < 5; ++j) {
  67.  
  68.             string hint = "Выделенный дорожный знак - \"";
  69.             if (data[i].type == "no_stop") {
  70.                 typeRus = "Остановка запрещена";
  71.             } else if (data[i].type == "give_way") {
  72.                 typeRus = "Уступи дорогу";
  73.             } else if (data[i].type == "bus_stop") {
  74.                 typeRus = "Остановка общественного транспорта";
  75.             } else if (data[i].type == "pedestrian") {
  76.                 typeRus = "Пешеходный переход";
  77.             } else {
  78.                 typeRus = "Главная дорога";
  79.             }
  80.             hint += typeRus;
  81.             hint += "\"";
  82.             string res = "false";
  83.             if (data[i].type == curSign[j]) {
  84.                 res = "true";
  85.             }
  86.             dataBin.emplace_back(data[i].url, curSignRus[j], res, hint);
  87. //            cout << data[i].url << '\t' << curSignRus[j] << '\t' << res << '\t' << hint << endl;
  88.         }
  89.     }
  90.     std::shuffle(begin(dataBin), end(dataBin), g);
  91.     for (size_t i = 0; i < 35; ++i) {
  92.         cout << dataBin[i].url << '\t' << dataBin[i].signRus << '\t' << dataBin[i].res << endl;
  93.     }
  94. //    ifstream tlkin;
  95. //    tlkin.open("Road_Signs/Боевые задания-Table 1.tsv");
  96. //    while (tlkin >> url >> type) {
  97. //        for (size_t j = 0; j < 5; ++j) {
  98. //            cout << url << '\t' << curSignRus[j] << '\t' << endl;
  99. //        }
  100. //    }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement