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

📄 pex8_11.cpp

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

#include "extset.h"	// include Set class with "-" and "~" operators

// compute the exclusive union of X and Y using the formula
// ExclusiveUnion = X*~Y + ~X*Y
template <class T>
Set<T> ExclusiveUnion(const Set<T>& X, const Set<T>& Y)
{
	return X*~Y + ~X*Y;
}

void main(void)
{
	// declare two integer sets X,Y with range 0..29 and two arrays
	// containing the initial values for sets X and Y
	Set<int>  X(30), Y(30);
	int  intX[8] = {1,3,4,5,7,8,12,20};
	int  intY[8] = {3,5,9,10,12,15,20,25};
	
	// initialize X and Y
	for (int i = 0; i < 8; i++)
	{
		X.Insert(intX[i]);
		Y.Insert(intY[i]);
	}	

	// test ExclusiveUnion
	cout << "X-Y = " << ExclusiveUnion(X,Y) << endl;
}

/*
<Run>

X-Y = {1, 4, 7, 8, 9, 10, 15, 25}
*/
	

⌨️ 快捷键说明

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