Advertisement
jasonpogi1669

Object Destructuring in C++

Aug 20th, 2021
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int n;
  7.     cin >> n;
  8.     map<int, int> connect;
  9.     for (int i = 0; i < n; i++) {
  10.         int a, b;
  11.         cin >> a >> b;
  12.         connect[a] = b;
  13.     }
  14.     // object destructuring
  15.     for (auto [a, b] : connect) {
  16.         cout << a << " " << b << '\n';
  17.     }
  18.     return 0;
  19. }
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement