Skip to content

Commit

Permalink
Practice-PI-20
Browse files Browse the repository at this point in the history
  • Loading branch information
Korablinov authored Jul 4, 2021
1 parent 48ee882 commit 7850f88
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions Задание 5/Вариант 3/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#include <iostream>
#include <iomanip>
#include <fstream>
Expand Down Expand Up @@ -165,7 +164,7 @@ void BinaryTree<T>::printTreeRecursively(Node<T> *root, Trunk *prev, bool isLeft
template<typename T>
void BinaryTree<T>::printTree(){
if (root == nullptr) {
cout<<"Tree is not exists!"<<endl;
cout<<"Дерева не существует!"<<endl;
} else {
printTreeRecursively(root, nullptr, false);
}
Expand All @@ -184,12 +183,12 @@ void BinaryTree<T>::printTableRecursively(Node<T> *node){
template<typename T>
void BinaryTree<T>::printTable() {
if (root == nullptr) {
cout<<"Tree is not exists!"<<endl;
cout<<"Дерева не существует!"<<endl;
}
else {
cout<<left;
cout <<setw(8)<< "|"<<setw(20) << "Surname" << setw(13)<< "|" << setw(10)<<"Marks"<<'\n' <<
setw(28) << "|---------------------------" << setw(10) << "| Math " << setw(10) << "| Physics " << setw(10) << "| Physics" << '\n';
cout <<setw(8)<< "|"<<setw(20) << "Фамилия" << setw(13)<< "|" << setw(10)<<"Оценки"<<'\n' <<
setw(28) << "|---------------------------" << setw(10) << "| Математика " << setw(10) << "| Физика " << setw(10) << "| История" << '\n';
printTableRecursively(root);
}
}
Expand Down Expand Up @@ -218,7 +217,7 @@ void BinaryTree<T>::saveTreeToFileRecursively(Node<T> *node, fstream& fs){
Student st = node->data;

if (!fs.is_open()){
cout<<"Unable to open file"<<endl;
cout<<"Не удалось открыть файл"<<endl;
} else{
fs<<st.getSurname()<<","<<st.getMathMark()<<","<<st.getPhysicsMark()<<","<<st.getHistoryMark()<<"\n";
}
Expand Down Expand Up @@ -284,7 +283,7 @@ void loadDataFromFile(BinaryTree<Student> &lst){
}
fs.close();
}
else cout << "Unable to open file";
else cout << "Не удалось открыть файл";
}

///MENU
Expand All @@ -309,16 +308,16 @@ void addNewStudent(BinaryTree<Student> &lst) {
int physicsMark;
int historyMark;

cout<<" New student"<<endl;
cout<<"Student's surname: ";
cout<<" Новый студент"<<endl;
cout<<"Фамилия студента: ";
cin>>surname;
cout<<"Math mark: ";
cout<<"Оценка по математике: ";
cin>>mathMark;
cout<<"Physics mark: ";
cout<<"Оценка по физике: ";
cin>>physicsMark;
cout<<"History mark: ";
cout<<"Оценка по истории: ";
cin>>historyMark;
cout<<"Done!"<<endl<<endl;
cout<<"Сделано"<<endl<<endl;

Student newStudent = *new Student(surname, mathMark, physicsMark, historyMark);
lst.addNode(newStudent);
Expand Down

0 comments on commit 7850f88

Please sign in to comment.