Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Лабораторная работа 32 / testgr / main
.cpp#include <iostream>
#include "CGraph.h"
#include "iterator.h"
#include<list>
#include "CCircle.h"
#include "CEllipse.h"
#include "CEllipseTxT.h"
#include "CText.h"
void main()
{
Shape* cir=new CCircle(0,0,1);
Shape* el=new CEllipse(0,1,2,1);
Shape* text=new CEllipseTxt(9,5, 2, 3,"hello");
Shape* elt=new CText(0,0,"hello 2");
CGraph<char*> graph;
graph.AddElement("A",1);
graph.AddElement("B",2);
graph.AddElement("C",3);
graph.AddElement("D",4);
graph.AddLine(1,2);
graph.AddLine(2,4);
graph.AddLine(4,2);
graph.AddLine(1,3);
graph.AddLine(2,3);
graph.printList();
graph.printElems();
graph.printLines();
CGraph<Shape*> graph2;
graph2.AddElement(cir,1);
graph2.AddElement(el,2);
graph2.AddElement(text,3);
graph2.AddElement(elt,4);
cout<<"Iterator: "<<endl;
GrIterator<Shape*> it2(graph2);
while (!it2.isEnd())
{
cout<<it2.currentElement()<<endl<<endl;
it2.goNext();
}
while (!it2.isBegin())
{
it2.goPred();
cout<<it2.currentElement()<<endl<<endl;
}
cout<<"--------------------------------------------"<<endl;
cout<<"Next ways"<<endl;
std::list<int> Ilist;
std::list<int>::iterator ItList;
Ilist=graph.getNextWays(3);
ItList=Ilist.begin();
while(ItList!=Ilist.end())
{
cout<<*ItList<<endl;
ItList++;
}
}
Соседние файлы в папке testgr