Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. int main(){
  8. int place[100000] = {0};
  9. int size1, size2, tmp;
  10. ifstream f;
  11. f.open("/Users/p/Documents/Saddle/Tasks24/input.txt");
  12. // f.open("input.txt");
  13. f >> size1;
  14. f >> size2;
  15.  
  16. for(int i=0; i < size1; i++){
  17. f >> tmp;
  18. if (place[tmp]==0) {
  19. place[tmp] = 1;
  20. cout << "num saved: " << tmp << "\n";
  21. }
  22. }
  23.  
  24. for(int i=0; i < size2; i++){
  25. f >> tmp;
  26. if (place[tmp]==1) {
  27. place[tmp] = 2;
  28. cout << "intersection found: " << tmp << "\n";
  29. }
  30. }
  31. f.close();
  32.  
  33. ofstream f2;
  34. f2.open("/Users/p/Documents/Saddle/Tasks24/output.txt");
  35. // f2.open("output.txt");
  36. for (int i=0; i <= 100000; i++){
  37. if (place[i]==2) f2 << i << " ";
  38. }
  39. f2.close();
  40.  
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement