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

📄 main.cpp

📁 本程序用VC++完成 定义类模板SortedSet (包括方法的实现)
💻 CPP
字号:
#include "StoredSet.cpp"
#include <iostream>
using namespace std;

int Compare(const double& n1, const double& n2);

int main()
{
	StoredSet<double> s(Compare, 20);
	cout<<"test insert:"<<endl;
	cout<<s.Insert(2.1)<<" ";
	cout<<s.Insert(-5.6)<<" ";
	cout<<s.Insert(0)<<" ";
	cout<<s.Insert(2.1)<<endl;
	cout<<"the count of storedset:"<<s.GetCount()<<endl;

	cout<<"test get :"<<endl;
	cout<<s.Get(1.3)<<" "<<s.Get(-1)<<" "<<s.Get(5.3)<<endl;
	
	cout<<"test del:"<<endl;
	cout<<s.Del(2.1)<<" ";
	cout<<s.Del(-5.6)<<" ";
	cout<<s.Del(0)<<" "<<s.Del(2.1)<<endl;
	return 0;
}

int Compare(const double& n1, const double& n2)
{
	if( (n1-n2>=0 && n1-n2<0.00001) || (n1-n2<0 && n1-n2>-0.00001 ) ) return 0;
	else if(n1>n2) return 1;
	else return -1;
}

⌨️ 快捷键说明

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