pex5_2.cpp

来自「数据结构C++代码,经典代码,受益多多,希望大家多多支持」· C++ 代码 · 共 40 行

CPP
40
字号
#include <iostream.h>
#pragma hdrstop

typedef int DataType;
#include "astack.h"

void main(void)
{
	Stack S;
	int a[10];
	
	// read 10 integers and push them onto S
	for (int i = 0; i < 10; i++)
	{
		cin >> a[i];
		S.Push(a[i]);
	}
	
	cout << endl << "Original list:";
	for(i=0;i < 10;i++)
		cout << a[i] << "  ";
	cout << endl << endl;
	
	// elements emerge from the stack in reverse
	cout << "Popping the stack: ";
	while (!S.StackEmpty())
		cout << S.Pop() << "  ";
	cout << endl;
}
/*
<Run>

1 3 4 7 8 10 13 15 19 24

Original list:1  3  4  7  8  10  13  15  19  24

Popping the stack: 24  19  15  13  10  8  7  4  3  1
*/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?