// 30_30-9.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include "stdafx.h"
#include <iostream>
#include <windows.h>
#include <set>

using namespace std;

void disp(set<int> &obj)
{
	set<int>::iterator wp;
	for (wp = obj.begin(); wp != obj.end(); wp++) {
		cout << *wp << " ";
	}
	cout << '\n';
}

int _tmain(int argc, _TCHAR* argv[])
{
	int n;
	int dt[] = { 40, 30, 70, 30, 50, 10, 20, 80, 60, 90 };
	set<int> s1;
	set<int> s2(dt, dt+10);
	set<int> s3;
	set<int>::iterator p;

	cout << "-----(1)s1に配列dtの値を設定し、s1とs2を表示\n";
	for (int i = 0; i < 10; i++) {
		s1.insert(dt[i]);
	}
	cout << "s1: ";
	disp(s1);
	cout << "s2: ";
	disp(s2);

	cout << "-----(2)40は登録されているか(find)\n";
	p = s1.find(40);
	if (p != s1.end()) {
		cout << "登録されている\n";
	}
	else {
		cout << "登録されていない\n";
	}

	cout << "-----(3)55は登録されているか(count)\n";
	n = s1.count(55);
	if (n != 0) {
		cout << "登録されている\n";
	}
	else {
		cout << "登録されていない\n";
	}

	cout << "-----(4)s3にs1をコピーする\n";
	s3 = s1;
	cout << "s3: ";
	disp(s3);

	cout << "-----(5)s3の60をfind+eraseで削除\n";
	p = s3.find(60);
	if (p != s3.end()) {
		s3.erase(p);
	}
	cout << "s3: ";
	disp(s3);

	cout << "-----(6)s3の70をcount+eraseで削除\n";
	if (s3.count(70) != 0) {
		s3.erase(70);
	}
	cout << "s3: ";
	disp(s3);

	MessageBox(NULL, _T("Check Console Window"), L"MessageBox", MB_OK);

	return 0;
}

