#include <iostream>
#include <vector>
using namespace std;
using std::vector;
int main(int argc, char const *argv[])
{
vector<int> v1;
vector<int> v2(10);
vector<int> v3(10, 42);
vector<int> v4{10};
vector<int> v5{10, 42};
vector<string> v6{10};
vector<string> v7{10, "Hi"};
vector<vector<int> > ivec = {v1, v2, v3, v4, v5};
vector<vector<string> > svec = {v6, v7};
int temp = 0;
for (auto iter = ivec.begin(); iter != ivec.end(); ++iter)
{
++temp;
if(iter->empty())
{
cout << "V" << temp << "is empty!" << endl;
}
else
{
int i = 0;
cout << "V" << temp << " is ->" << endl;
for(auto it = (*iter).begin(); it != (*iter).end(); ++it)
{
++i;
cout << "Number_"<< i << " is ";
cout << *it << endl;
}
}
}
for (auto iter = svec.begin(); iter != svec.end(); ++iter)
{
++temp;
if(iter->empty())
{
cout << "V" << temp << "is empty!" << endl;
}
else
{
int i = 0;
cout << "V" << temp << " is ->" << endl;
for(auto it = (*iter).begin(); it != (*iter).end(); ++it)
{
++i;
cout << "String_"<< i << " is ";
cout << *it << endl;
}
}
}
// for (int i = 0; i != 5; ++i)
// {
// if (ivec[i].empty())
// {
// cout << "v" << i + 1 << " is empty!" << endl;
// }
// else
// {
// cout << "v" << i + 1 << " is begin" << endl;
// for (int j = 0; j != ivec[i].size(); ++j)
// {
// vector<int> temp;
// temp = ivec[i];
// cout << temp[j];
// cout << "-->";
// cout << endl;
// }
// }
// }
// for (int i = 0; i != 2; ++i)
// {
// if (svec[i].empty())
// {
// cout << "v" << i + 6 << " is empty!" << endl;
// }
// else
// {
// cout << "v" << i + 6 << " is begin" << endl;
// for (int j = 0; j != svec[i].size(); ++j)
// {
// vector<string> temp;
// temp = svec[i];
// cout << temp[j];
// cout << "-->";
// cout << endl;
// }
// }
// }
system("pasue");
return 0;
}
标签:10,cout,temp,ivec,5th,iter,3.21,vector,Primer
From: https://www.cnblogs.com/unrivalled/p/16977514.html