#include <iostream>using namespace STD;Template<intN>classbitset{ Public: BitSet () {Set(); }void Set() { for(inti =0; i < Nm; i++) {Vtr[i] =0; } }void Set(intN) {vtr[(n1) / +] |= (0x1<< ((n1) % +)); }voidPrintf () { for(inti = N; i >0; i--) {cout<< (((Vtr[(i1)/ +]>> ((I-1)% +)) &0x1) ==0?"0":"1"); } }BOOLTestintN) {if(Vtr[(n1) / +] >> (n1) % +) &0x1)return true;return false; }Private:enum{_n_= (n1) / (sizeof(size_t) *8)};enum{nm=_n_+1};intVTR[NM];};intMain () {bitset<344> bt; Bt.Set( +);//So a simple bitset is done to find out whether there is a number in a large amount of data. if(Bt.test ( +)) {cout<<"This location exists"<< Endl; }Else{cout<<"The location does not exist"<< Endl; } BT. Printf ();return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
C + + simple version Bitset solve large amount of data existence MO number