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


C++ Pila::peek方法代码示例

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


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

示例1: main

int main(int argc, char **argv) {

	srand(time(NULL));
	string s[30] = { "Diego", "Maria", "Juan", "Andres", "Pedro", "Luis",
		"Juana", "Siria", "Roberto", "Siria", "Sebastian", "Ricardo",
		"Aria", "Andrey", "Chris", "Jose", "Ana", "Tyler", "Alberto",
		"Carolina", "Catalina", "Leonardo", "Walter", "Helen", "Silvia",
		"Monse", "Camila", "Carlos", "Aracely", "Mario" };

	Pila p;
	
	for (int w = 0; w < 10; ++w) {

		Persona* p1 = new Persona(rand() % 1000, s[rand() % 30], rand() % 100);
		ElementoPersona *p11 = new ElementoPersona(p1);
		p.push(p11);

	}

	cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << endl;
	cout << endl;
	cout << "Pila de personas" << endl;
	cout << endl;
	cout << p << endl;
	cout << "--------------------------------------------------------" << endl;
	cout << endl;
	cout << "Haciendo PEEK" << endl;
	cout << endl;
	p.peek();
	cout << "--------------------------------------------------------" << endl;
	cout << endl;
	cout << "Haciedno POP" << endl;
	cout << endl;
	p.pop();
	cout << "--------------------------------------------------------" << endl;
	cout << endl;
	cout << "Imprimiendo Pila despues del POP" << endl;
	cout << endl;
	cout << p << endl;

	Pila p2;

	for (int h = 0; h < 10; ++h) {

		ElementoInt *p22 = new ElementoInt(rand() % 1000);
		p2.push(p22);

	}

	cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << endl;
	cout << endl;
	cout << "Pila de Enteros" << endl;
	cout << endl;
	cout << p2 << endl;
	cout << "--------------------------------------------------------" << endl;
	cout << endl;
	cout << "Haciendo PEEK" << endl;
	cout << endl;
	p2.peek();
	cout << "--------------------------------------------------------" << endl;
	cout << endl;
	cout << "Haciedno POP" << endl;
	cout << endl;
	p2.pop();
	cout << "--------------------------------------------------------" << endl;
	cout << endl;
	cout << "Imprimiendo Pila despues del POP" << endl;
	cout << endl;
	cout << p2 << endl;

	Pila p3;

	for (int g = 0; g < 10; ++g) {

		ElementoDouble *p33 = new ElementoDouble(rand() % 1000);
		p3.push(p33);

	}

	cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << endl;
	cout << endl;
	cout << "Pila de Doubles" << endl;
	cout << endl;
	cout << p3 << endl;
	cout << "--------------------------------------------------------" << endl;
	cout << endl;
	cout << "Haciendo PEEK" << endl;
	cout << endl;
	p3.peek();
	cout << "--------------------------------------------------------" << endl;
	cout << endl;
	cout << "Haciedno POP" << endl;
	cout << endl;
	p3.pop();
	cout << "--------------------------------------------------------" << endl;
	cout << endl;
	cout << "Imprimiendo Pila despues del POP" << endl;
	cout << endl;
	cout << p3 << endl;

//.........这里部分代码省略.........
开发者ID:Xbulldcm,项目名称:LaboratorioPila,代码行数:101,代码来源:Main.cpp


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