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

📄 pex8_10.cpp

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

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

void main(void)
{
	// declare two integer sets A,B with range 0..14 and two arrays
	// containing the initial values for sets A and B
	Set<int>  A(15), B(15);
	int  intA[10] = {1, 2, 3, 4, 6, 7, 9, 10, 11, 14};
	int  intB[10] = {0, 3, 4, 5, 6, 7, 8, 12, 13, 14};
	
	// initialize A and B
	for (int i = 0; i < 10; i++)
	{
		A.Insert(intA[i]);
		B.Insert(intB[i]);
	}	
	
	// print A and B. compute and print A-B and B-A
	cout << "A = " << A << endl;
	cout << "B = " << B << endl;
	cout << "A-B = " << (A - B) << endl;
	cout << "B-A = " << (B - A) << endl;
	
	// demonstrate that A+B = (A-B)+(B-A)+(A*B)
	cout << "A+B = " << (A + B) << endl;
	cout << "(A-B)+(B-A)+(A*B) = "
		 << ((A - B) + (B - A) + (A * B)) << endl;
}

/*
<Run>

A = {1, 2, 3, 4, 6, 7, 9, 10, 11, 14}
B = {0, 3, 4, 5, 6, 7, 8, 12, 13, 14}
A-B = {1, 2, 9, 10, 11}
B-A = {0, 5, 8, 12, 13}
A+B = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}
(A-B)+(B-A)+(A*B) = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}
*/

	

⌨️ 快捷键说明

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