- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- template <typename Type>
- struct Print
- {
- void operator ()(Type& item)
- {
- cout << item << '/t';
- }
- };
- int main(int argc, char *argv[])
- {
- int m, n;
- int position;
- cin >> m >> n;
- vector<int> vec(n);
- position = n - 1;
- for (int i = 0; i <= position; ++i)
- {
- vec[i] = i + 1;
- }
- for_each(vec.begin(), vec.end(), Print<int>());
- cout << endl;
- while (true)
- {
- if (vec[n - 1] == m)
- {
- --position;
- }
- else
- {
- position = n - 1;
- }
- ++vec.at(position);
- for (int i = position + 1; i < n; ++i)
- {
- vec.at(i) = vec.at(i - 1) + 1;
- }
- for_each(vec.begin(), vec.end(), Print<int>());
- cout << endl;
- if (vec.at(0) >= m - n + 1)
- {
- break;
- }
- }
- return 0;
- }