Last active
August 29, 2015 14:12
-
-
Save Jeswang/5f73aaf8625f1ad38d6d to your computer and use it in GitHub Desktop.
find same ints in two file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
#include <bitset> | |
#include <queue> | |
#include <vector> | |
#include <functional> | |
using namespace std; | |
bitset<4294967296> bits; | |
priority_queue<int, vector<int>, greater<int> > res; | |
int main(int argc, char *argv[]) { | |
ifstream inf("file1"); | |
long long index; | |
while(inf>>index) { | |
index += 2147483648; | |
bits.set(index); | |
} | |
ifstream inf2("file2"); | |
while(inf2>>index) { | |
index += 2147483648; | |
if(bits[index]) { | |
res.push(index-2147483648); | |
} | |
} | |
while(!res.empty()) { | |
cout<<res.top()<<endl; | |
res.pop(); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment