本文整理汇总了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;
//.........这里部分代码省略.........