搞不好人家只是要你用stl跟c++11而已
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdint>
int main() {
std::vector<int> one_to_nine(9);
int i = 1;
std::for_each(one_to_nine.begin(), one_to_nine.end(),
[&i](int& n) { n = i++; }
);
auto l = [&one_to_nine](int j) {
std::for_each(one_to_nine.begin(), one_to_nine.end(),
[&one_to_nine, j](const int i) {
std::cout << i << " x " << j << " = " << i * j << " ";
});
};
std::for_each(one_to_nine.begin(), one_to_nine.end(),
[&i, &l](int& n) {
l(n);
std::cout << std::endl;
});
return 0;
}