当前位置: 首页>>代码示例>>C++>>正文


C++ PriorityQueue::printPQ方法代码示例

本文整理汇总了C++中PriorityQueue::printPQ方法的典型用法代码示例。如果您正苦于以下问题:C++ PriorityQueue::printPQ方法的具体用法?C++ PriorityQueue::printPQ怎么用?C++ PriorityQueue::printPQ使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PriorityQueue的用法示例。


在下文中一共展示了PriorityQueue::printPQ方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main() {
	PriorityQueue<string> pq;
	PQVector<string> pqv;
	
		string elem;
	
	int what = 1;
	cout << "1. Priority Queue with Binary Heap\n2. Priority Queue with Vector\nChoic: ";
	cin >> what;
if(what ==1){
	string again, right, left;
	left = 'y'; 	right = 'Y'; 	again = 'Y';
	

	
	elem = "abc"; pq.insertItem(3, elem);
	elem = "2ab"; pq.insertItem(4, elem);
	elem = "bbc"; pq.insertItem(1, elem);
	elem = "cnn"; pq.insertItem(5, elem);
	elem = "ddn"; pq.insertItem(6, elem);
	elem = "eda"; pq.insertItem(7, elem);
	elem = "ggg"; pq.insertItem(9, elem);
	elem = "kkk"; pq.insertItem(10, elem);
	elem = "lll"; pq.insertItem(11, elem);
	elem = "mmm"; pq.insertItem(12, elem);

	// elem = "qqq"; pq.insertItem(16, elem);
	
	cout << "\nAlready inserted heaps\n";
	cout << "===============\n";
	pq.printPQ();
	cout << "===============\n";
	// cout << "---------Before Removing Min\n";
	// cout << "minElement: " << pq.minElement() << endl;
	// cout << "minKey: " << pq.minKey() << endl;
	// cout << "Min element removed." << endl;
	// pq.remove(pq.min());
	// cout << "--------After removing min\n";	
	// cout << "minElement: " << pq.minElement() << endl;
	// cout << "minKey: " << pq.minKey() << endl;	
	
	// pq.decreaseKey(pq.min(),pq.minKey());
	
	// cout << "--------After decreasing loc 3\n";
	// pq.decreaseKey(3,6);

	// cout << "================\n";
	
	// pq.decreaseKey(pq.minKey(), pq.min());

	
	
	while (again.compare(right) == 0 || again.compare(left) == 0)
	{
		char choi;
		cout << "What would you like to do? (Press corresponding number and hit enter)"<<endl;
		cout << "1. Insert items into a priority queue."<<endl;
		cout << "2. Print out priority queue."<<endl;
		cout << "3. Remove an item with a specific location."<<endl;
		cout << "4. Find item with minimum key."<<endl;
		cout << "5. Decrease Key."<<endl;
		cout << "6. Build Priority Queue." << endl;
		cout << "7. Exit."<<endl;
		cout << "Choie: ";
		cin >> choi;
		
		if(choi == '1')
		{
			int key;
			char element[255];
			
			cout << "Key: ";
			cin >> key;
			cout << "Elem: ";
			cin >> element;
			pq.insertItem(key, element);
		}
		else if(choi == '2')
开发者ID:leecom3025,项目名称:CSCE221_PriorityQueue,代码行数:78,代码来源:Queuemain.cpp


注:本文中的PriorityQueue::printPQ方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。