We use STL pair to store two values together.
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
pair<int, int> p;
pair<string, int> f;
pair<char, double> g;
// To make a vector pair
int n;
cin >> n;
vector<pair<int, int>> v(n);
for(int i = 0 ; i < n ; i++){
cin >> v[i].first >> v[i].second ;
}
for(int i = 0 ; i < n ; i++){
cout << v[i].first << " " << v[i].second << endl ;
}
p = make_pair(2, 3);
f = make_pair("Mujahida", 3);
cout << f.first << endl;
cout << f.second << endl;
cout << p.first << endl;
cout << p.second << endl;
}
Top comments (0)