ProgMe

Duty list

Jan 25th, 2021 (edited)
569
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <string>
  4. #include <vector>
  5. #include <ctime>
  6.  
  7. int pref_months[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; // Days in month
  8.  
  9. std::vector<std::string> list ={
  10.         "Anisevich Egor",
  11.         "Ardytskaya Karina",
  12.         "Basik Denis",
  13.         "Bychkovski Roman",
  14.         "Evtikhov Artyom",
  15.         "Karpuk Maksim",
  16.         "Koliada Ilya",
  17.         "Kuchinski Ilya",
  18.         "Luksha Maria",
  19.         "Parkhomenko Sasha",
  20.         "Petlyova Sasha",
  21.         "Polyakov Roman",
  22.         "Prokopenia Karina",
  23.         "Saevets Sofia",
  24.         "Savcuk Emma",
  25.         "Shepel Katia",
  26.         "Shimanskaya Efrosinia",
  27.         "Silenkova Dasha",
  28.         "Stepanuk Kirill",
  29.         "Zhuk Ksenia"
  30. }; // Main list of the klass
  31.  
  32. int32_t main() {
  33.     /*std::ifstream fin("klass.txt");
  34.     std::string now;
  35.     while(std::getline(fin, now))
  36.         list.push_back(now);*/ //Add some people
  37.     std::sort(list.begin(), list.end()); //Sort of the list
  38.     for(int month = 1; month <= 12; month++)
  39.         pref_months[month] += pref_months[month - 1]; //Count prefix sums for 1..12
  40.     time_t t;
  41.     struct tm *tm;
  42.     int day, month;
  43.     t = time(nullptr); //
  44.     tm = localtime(&t); //Get localtime
  45.     day = tm->tm_mday; //Get day
  46.     month = tm->tm_mon; // Get month
  47.     int today_duty = (pref_months[month - 1] + day) % list.size(); //Who is on duty
  48.     std::cout << list[today_duty]; //Print, who is on duty
  49. }
RAW Paste Data