SHOW:
|
|
- or go back to the newest paste.
| 1 | - | // Alexeev N.E. |
| 1 | + | |
| 2 | #include <string> | |
| 3 | - | #include <vector> |
| 3 | + | #include <map> |
| 4 | - | #include <ctime> |
| 4 | + | |
| 5 | - | #include <iomanip> |
| 5 | + | using namespace std; |
| 6 | - | #include <algorithm> |
| 6 | + | |
| 7 | - | #include <random> |
| 7 | + | class Student {
|
| 8 | ||
| 9 | - | #define SIZE 10 |
| 9 | + | protected: |
| 10 | ||
| 11 | - | void reverse(std::vector<int> &vector) |
| 11 | + | string m_name; |
| 12 | int m_id; | |
| 13 | - | std::cout << "REVERSE\n"; |
| 13 | + | |
| 14 | - | std::reverse(vector.begin(), vector.end()); |
| 14 | + | public: |
| 15 | - | } |
| 15 | + | |
| 16 | const string &getName() const {
| |
| 17 | - | void sortHigh(std::vector<int>& vector) |
| 17 | + | return m_name; |
| 18 | } | |
| 19 | - | std::cout << "Sort Ascending\n"; |
| 19 | + | |
| 20 | - | std::sort(vector.begin(), vector.end()); |
| 20 | + | void setName(const string &name) {
|
| 21 | - | } |
| 21 | + | Student::m_name = name; |
| 22 | } | |
| 23 | - | void sortLess(std::vector<int>& vector) |
| 23 | + | |
| 24 | int getId() const {
| |
| 25 | - | std::cout << "Sort Descending\n"; |
| 25 | + | return m_id; |
| 26 | - | std::sort(vector.rbegin(), vector.rend()); |
| 26 | + | } |
| 27 | - | } |
| 27 | + | |
| 28 | void setId(int id) {
| |
| 29 | - | using funcType = void (*)(std::vector<int>&); |
| 29 | + | Student::m_id = id; |
| 30 | - | funcType check(std::vector<int>& vector) |
| 30 | + | } |
| 31 | ||
| 32 | - | int sum = 0; |
| 32 | + | }; |
| 33 | - | for(auto& now : vector) |
| 33 | + | |
| 34 | - | sum += now; |
| 34 | + | class HeadMan : public Student |
| 35 | - | if (sum == vector[0]) |
| 35 | + | |
| 36 | - | return reverse; |
| 36 | + | |
| 37 | - | if (sum > vector[0]) |
| 37 | + | private: |
| 38 | - | return sortHigh; |
| 38 | + | |
| 39 | - | if (sum < vector[0]) |
| 39 | + | map <string, Student> m_listOfStudents; // список студентов с номерами телефонов |
| 40 | - | return sortLess; |
| 40 | + | map <bool, Student> m_listOfMissing; // список посещеаемости на одну пару |
| 41 | - | std::cerr << "Fatal error!"; |
| 41 | + | |
| 42 | - | exit(0); |
| 42 | + | public: |
| 43 | - | } |
| 43 | + | |
| 44 | const map<string, Student> &getListOfStudents() const {
| |
| 45 | - | int main() |
| 45 | + | return m_listOfStudents; |
| 46 | } | |
| 47 | - | std::mt19937 gen(static_cast<unsigned int>(time(nullptr))); |
| 47 | + | |
| 48 | - | std::uniform_int_distribution<int> dist(-100, 100); |
| 48 | + | void setListOfStudents(const map<string, Student> &listOfStudents) {
|
| 49 | - | std::vector<int> vec(SIZE); |
| 49 | + | HeadMan::m_listOfStudents = listOfStudents; |
| 50 | - | for(auto& now : vec) |
| 50 | + | } |
| 51 | - | now = dist(gen); |
| 51 | + | |
| 52 | const map<bool, Student> &getListOfMissing() const {
| |
| 53 | - | std::cout << "Array:\n"; |
| 53 | + | return m_listOfMissing; |
| 54 | - | for(auto& now : vec) |
| 54 | + | } |
| 55 | - | std::cout << std::setw(4) << now << ' '; |
| 55 | + | |
| 56 | - | std::cout << std::endl; |
| 56 | + | void setListOfMissing(const map<bool, Student> &listOfMissing) {
|
| 57 | HeadMan::m_listOfMissing = listOfMissing; | |
| 58 | - | funcType funcPtr = check(vec); |
| 58 | + | } |
| 59 | - | funcPtr(vec); |
| 59 | + | |
| 60 | }; | |
| 61 | - | std::cout << "Array after check:\n"; |
| 61 | + | |
| 62 | - | for(auto& now : vec) |
| 62 | + | int main() {
|
| 63 | - | std::cout << std::setw(4) << now << ' '; |
| 63 | + | std::cout << "Hello, World!" << std::endl; |
| 64 | return 0; | |
| 65 | } |