#include
using namespace std;
int main() {
int n,k10,k5,k2,k1,k;
cout << "n = ", cin >> n, cout << "\n";<br> k = 0;
for (k10=0; k10<=n / 10; k10++)<br> for (k5=0; k5<=(n-10*k10) / 5; k5++) <br> for (k2=0; k2<=(n-10*k10-5*k5) / 2; k2++) {<br> k1 = n-10*k10-5*k5-2*k2;
cout << k10 << " " << k5 << " " << k2 << " " << k1 << "\n";<br> k = k+1;
}
cout << "k = " << k;<br> return 0;
}
Пример:
n = 16
0 0 0 16
0 0 1 14
0 0 2 12
0 0 3 10
0 0 4 8
0 0 5 6
0 0 6 4
0 0 7 2
0 0 8 0
0 1 0 11
0 1 1 9
0 1 2 7
0 1 3 5
0 1 4 3
0 1 5 1
0 2 0 6
0 2 1 4
0 2 2 2
0 2 3 0
0 3 0 1
1 0 0 6
1 0 1 4
1 0 2 2
1 0 3 0
1 1 0 1
k = 25