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
|
#include <iostream>
#include <vector>
#include <string>
void print(const std::string& label, const std::vector<double>& v);
int main()
{
std::vector<double> v1 = {6,7,8,9,10};
std::vector<double> v2 = {1,2,3,4,5};
std::vector<double> v3 = {11,12,13,14,15};
std::string label_v1 = "v1";
std::string label_v2 = "v2";
std::string label_v3 = "v3";
print(label_v1, v1);
print(label_v2, v2);
print(label_v3, v3);
return 0;
}
void print(const std::string& label, const std::vector<double>& v)
{
for(int i = 0; i<v.size(); i++)
{
if (i == 0)
{
std::cout << label << " = " << v[i] << ", ";
}
else
{
std::cout << v[i] << ", ";
}
}
std::cout << "\n\n";
}
|