Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main ()
  6. {
  7. int n,x,y, s=0;
  8. int c;
  9. cin >> n;
  10. int a[100][2] = {0};
  11. for (int i=1; i<2*n; i+=2)
  12. {
  13. cout <<i<<" "<<i+1<<endl;
  14. if (!(cin >> x))
  15. {
  16. s+=1;
  17. cin.clear();
  18. cin.ignore(10, '\n');
  19. }
  20. else
  21. {
  22. if (x == -1) {return 0;}
  23. cin >> y;
  24. if (a[x][0] == 0) a[x][0] = i;
  25. else a[x][1] = i;
  26. if (a[y][0] == 0) a[y][0] = i+1;
  27. else a[y][1] = i+1;
  28. }
  29. }
  30. for (int i=1; i<=n-s; i++)
  31. {
  32. if (a[i][0] != 0)
  33. {cout << a[i][0] <<" " << a[i][1]<<endl;}
  34. if (!(cin >> c))
  35. {
  36. cin.clear();
  37. cin.ignore(10, '\n');
  38. }
  39. else return 0;
  40. }
  41. cout << -1;
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement