multiset
This commit is contained in:
		
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										41
									
								
								STL/STL-Set/multiset.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								STL/STL-Set/multiset.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,41 @@
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include <set>//Ҳ<><D2B2>set
 | 
			
		||||
using namespace std;
 | 
			
		||||
 | 
			
		||||
class compare{
 | 
			
		||||
public:
 | 
			
		||||
	template <class T>
 | 
			
		||||
	bool operator()(const T& a, const T& b){
 | 
			
		||||
		return a > b;
 | 
			
		||||
	}	
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
int main(){
 | 
			
		||||
	auto cmpl = [](auto a, auto b){
 | 
			
		||||
		return a < b;
 | 
			
		||||
	};
 | 
			
		||||
	multiset<int> a{1,1,2,3,3,3,4,5,6,7,7,7,10};
 | 
			
		||||
	multiset<int, decltype(cmpl)> b(cmpl);
 | 
			
		||||
	b.insert({14,16,20,18,2,2,2,4,4,6,6,8,8,10,12});
 | 
			
		||||
	multiset<int, compare> c{1,3,5,7,9,11,11,11,13};
 | 
			
		||||
	for(int x : a){
 | 
			
		||||
		cout << x << " ";
 | 
			
		||||
	}cout << endl;
 | 
			
		||||
	for(int x : b){
 | 
			
		||||
		cout << x << " "; 
 | 
			
		||||
	}cout << endl;
 | 
			
		||||
	for(int x : c){
 | 
			
		||||
		cout << x << " ";
 | 
			
		||||
	}cout << endl;
 | 
			
		||||
	cout << b.count(2) << endl;
 | 
			
		||||
	cout << *b.upper_bound(6) << " " << *b.lower_bound(6) << endl;
 | 
			
		||||
	return 0;
 | 
			
		||||
} 
 | 
			
		||||
/*
 | 
			
		||||
1 1 2 3 3 3 4 5 6 7 7 7 10
 | 
			
		||||
2 2 2 4 4 6 6 8 8 10 12 14 16 18 20
 | 
			
		||||
13 11 11 11 9 7 5 3 1
 | 
			
		||||
3
 | 
			
		||||
8 6
 | 
			
		||||
*/
 | 
			
		||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>setһ<74>£<EFBFBD><C2A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>ظ<EFBFBD>Ԫ<EFBFBD><D4AA> 
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
		Reference in New Issue
	
	Block a user