⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pex12_11.cpp

📁 数据结构C++代码,经典代码,受益多多,希望大家多多支持
💻 CPP
字号:
#include <iostream.h>
#pragma hdrstop

#include "wex12_20.h"
#include "array.h"
#include "arriter.h"
#include "seqlist2.h"

void main(void)
{
	// declare two objects for which iterators will be used
	// to determine the maximum value
	Array<int> A(10);
	SeqList<char> L;
	
	// assign the values 1,2,3,...10 to A
	for(int i=0;i < 10;i++)
		A[i] = i+1;

	// create sequential list L = {'a','b','c','d','e'}
	for(char c = 'a';c <= 'e';c++)
		L.Insert(c);
		
	// declare an iterator for each object
	ArrayIterator<int> arriter(A);
	SeqListIterator<char> liter(L);
	
	// apply Max to determine the maximum value in each collection
	cout << "Maximum in the Array object is " << Max(arriter) << endl;
	cout << "Maximum in the SeqList object is " << Max(liter) << endl;	
}

/*
<Run>

Maximum in the Array object is 10
Maximum in the SeqList object is e
*/

⌨️ 快捷键说明

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