Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void printDisciplines()
- {
- ofstream out("ListOfDisciplines.txt");
- out << " ";
- for (int i = 0; i < 47; ++i)
- out << '_';
- out << endl << "/ \\" << endl;
- out << "| SORTED LIST OF DISCIPLINES |" << endl;
- out << "\\";
- for (int i = 0; i < 47; ++i)
- out << '_';
- out << "/" << endl;
- out << "/ | \\" << endl;
- out << "| Discipline |Number of Copies|" << endl;
- out << "|______________________________|________________|" << endl;
- unsigned long long counter;
- String curMin;
- String last = "0";
- bool found = false;
- while (curMin != last)
- {
- if (curMin[0] != '\0')
- last = curMin;
- curMin = "я";
- counter = 0;
- found = false;
- for (Node* ptr = this->front; ptr != back; ptr = ptr->next)
- {
- unsigned char firstChar = static_cast<unsigned char>(ptr->data->getDiscipline()[0]);
- if (firstChar < static_cast<unsigned char>(curMin[0]) && (last[0] == '\0' || static_cast<unsigned char>(last[0]) < firstChar))
- {
- curMin = ptr->data->getDiscipline();
- found = true;
- }
- else if (firstChar == static_cast<unsigned char>(curMin[0]) && (last[0] == '\0' || static_cast<unsigned char>(last[0]) == firstChar))
- for (unsigned int j = 0; true; ++j)
- if (static_cast<unsigned char>(ptr->data->getDiscipline()[j]) > static_cast<unsigned int>(curMin[j]))
- break;
- else if (static_cast<unsigned char>(ptr->data->getDiscipline()[j]) < static_cast<unsigned char>(curMin[j]))
- {
- curMin = ptr->data->getDiscipline();
- found = true;
- break;
- }
- }
- for (Node* ptr = this->front; ptr != back; ptr = ptr->next)
- if (ptr->data->getDiscipline() == curMin)
- counter += ptr->data->getNumberOfCopies();
- if (found)
- {
- out << '|';
- out.setf(ios::left);
- out.width(30);
- out << curMin << '|';
- out.width(16);
- out << counter << '|' << endl;
- }
- }
- out << "\\______________________________|________________/" << endl;
- out.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement