Vector of Pairs of integers
I'm asked to get a value N
and I will then get N
pairs of values. These pairs will be the size of my 2D array, and this 2D array's elements will range from 1 to the size of the 2D array.
Sample input:
N = 2
Two pairs of values are
(2,3)
(3,4)
Sample output:
{(1,2,3),(4,5,6)}
{(1,2,3,4),(5,6,7,8),(9,10,11,12)}
The below code is what I have tried. I'm still a beginner so kindly help me.
#include<bits/stdc++.h>
using namespace std;
makeArray(int a, int b){
int arr[a][b];
int temp = 1;
cout<<"[";
for(int i=1; i<=a; i++){
cout<<"[";
for(int j=1; j<=b; j++){
cout<<temp<<",";
}
cout<<"]";
}
cout<<"]";
}
int main() {
int n;
cin>>n;
int a,b;
vector<pair<int,int>> ip;
for(int i=0; i<n; i++){
cin>>a;
cin>>b;
ip.push_back(make_pair(a,b));
}
for (int x=0; x<n; x++)
{
makeArray(ip.first, ip.second);
cout<<endl;
}
return 0;
}
from Recent Questions - Stack Overflow https://ift.tt/3uewsTe
https://ift.tt/eA8V8J
Comments
Post a Comment