
Добавил:
Tushkan
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Лабораторные работы (2) / laba13 / File1
.cpp//---------------------------------------------------------------------------
#pragma hdrstop
#include <conio.h>
#include <class.cpp>
#include <deq.cpp>
//---------------------------------------------------------------------------
#pragma argsused
void Print(BiList<int> p){
for ( BiList<int>::iterator it = p.begin(); it != p.end(); it++) {
cout << *it<< " ";
}
if (p.begin() == p.end()) {
cout <<"EMPTY";
}
cout << endl;
}
void main()
{
BiList<int> p;
cout << "1) start"<<endl;
Print(p);
cout << "size="<<p.size()<<endl;
cout << "empty="<<p.empty()<<endl;
cout << "2) add 6"<<endl;
p.push_back(6);
Print(p);
cout << "size="<<p.size()<<endl;
cout << "empty="<<p.empty()<<endl;
cout << "3) add 5"<<endl;
p.push_front(5);
Print(p);
cout << "size="<<p.size()<<endl;
cout << "empty="<<p.empty()<<endl;
cout << "4) add 3"<<endl;
p.push_back(3);
Print(p);
cout << "size="<<p.size()<<endl;
cout << "empty="<<p.empty()<<endl;
cout << "5) remove"<<endl;
BiList<int>::iterator it = p.begin();
it++;
it.remove();
Print(p);
cout << "size="<<p.size()<<endl;
cout << "empty="<<p.empty()<<endl;
cout << "6) insert 2"<<endl;
it = p.begin();
//it++;
it.insert(2);
Print(p);
cout << "size="<<p.size()<<endl;
cout << "empty="<<p.empty()<<endl;
cout << "7) clear"<<endl;
p.clear();
Print(p);
cout << "size="<<p.size()<<endl;
cout << "empty="<<p.empty()<<endl;
Deq<int, 5> q;
cout << "empty = " << q.empty() << endl;
cout << "size = " << q.GetSize()<< endl;
cout << "1) push back 2 - 2" << endl;
q.push_back(2);
cout << "empty = " << q.empty() << endl;
cout << "size = " << q.GetSize()<< endl;
cout << "2) push back 1 - 2 1" << endl;
q.push_back(1);
cout << "empty = " << q.empty() << endl;
cout << "size = " << q.GetSize()<< endl;
cout << "3) push front 3 - 3 2 1" << endl;
q.push_front(3);
cout << "empty = " << q.empty() << endl;
cout << "size = " << q.GetSize()<< endl;
cout << "back = " <<q.back()<<endl;
cout << "front = "<<q.front() << endl;
cout << "4) push front 4 - 4 3 2 1" << endl;
q.push_front(4);
cout << "empty = " << q.empty() << endl;
cout << "size = " << q.GetSize()<< endl;
cout << "5) push front 5 - 5 4 3 2 1" << endl;
q.push_front(5);
cout << "empty = " << q.empty() << endl;
cout << "size = " << q.GetSize()<< endl;
cout << "6) Result - 5 4 3 2 1" << endl;
for (int i = 0; i < 5; i++)
cout << q.pop_front()<< " ";
getch();
}
//---------------------------------------------------------------------------
Соседние файлы в папке laba13