Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <vector>
- struct lesson {
- std::string name;
- unsigned int length;
- };
- int compare_lessons(const lesson &left, const lesson &right) {
- return right.name.compare(left.name) < 0;
- }
- void print_vector(std::vector<lesson> lessons, int week = 1) {
- std::cout << "Week " << week << ": " << std::endl;
- std::string days[] = {
- "Monday",
- "Tuesday",
- "Wednesday",
- "Thursday",
- "Friday",
- "Saturday",
- "Sunday"
- };
- int day = 0;
- for (size_t i = 0; i < lessons.size(); i++) {
- std::cout << days[(day) % 7] << std::endl;
- std::cout << lessons[i].name << std::endl;
- i++;
- std::cout << lessons[i].name << std::endl;
- day++;
- }
- std::cout << std::endl;
- }
- int main() {
- std::vector<lesson> lessons;
- lesson temp;
- do {
- std::cout << "Subject name: ";
- std::cin >> temp.name;
- if (temp.name != "exit") {
- lessons.push_back(temp);
- }
- } while (temp.name != "exit");
- std::sort(lessons.begin(), lessons.end(), compare_lessons);
- int week = 1;
- do {
- print_vector(lessons, week++);
- } while (
- std::next_permutation(lessons.begin(), lessons.end(), compare_lessons));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement