main.cpp

来自「本程序用VC++完成 定义类模板SortedSet (包括方法的实现)」· C++ 代码 · 共 32 行

CPP
32
字号
#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 + =
减小字号Ctrl + -
显示快捷键?