1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
#include <iostream>
#include <vector>
void obtain(std::vector<int>&, double&, std::vector<std::vector<int>>&);
void use(std::vector<int>&, double&, std::vector<std::vector<int>>&);
int main()
{
std::vector<int> v;
double d;
std::vector<std::vector<int>> v2d;
obtain(v, d, v2d);
use(v, d, v2d);
}
void obtain(std::vector<int>& v, double& d, std::vector<std::vector<int>>& v2d)
{
v = { 1, 2, 3 };
d = 1.23;
v2d = { { 1, 3, 5 }, { 2, 4, 6 } };
}
void use(std::vector<int>& v, double& d, std::vector<std::vector<int>>& v2d)
{
for ( auto& itr : v ) { std::cout << itr << ' '; }
std::cout << "\n\n";
std::cout << d << "\n\n";
for ( auto& row : v2d )
{
for ( auto& col : row )
{
std::cout << col << ' ';
}
std::cout << '\n';
}
}
|