"Given two nonnegative integer numbers m and n, generate all m-size combinations of integers from 0 to n-1, in ascending order.
Example: m = 3 and n = 5
(0 1 2); (0 1 3); (0 1 4); (0 2 3); (0 2 4); (0 3 4); (12); (1 2 4); (1 3 4); (2 3 4) "
I do not know how to solve this exercise. The most I could do was create the vector 0 1 2. I realized that I need to add 1 to the last element until it reaches the value n-1, then I get the vector 0 1 2 again and add 1 to the last two elements, then only to the last one and so on. But I do not know how to do that. I thought of using a FOR for each round of sums, but in case the amount of FORs would depend on the value of m and the algorithm should serve any values of m and n, so I understood.
public static void main(String[] args) {
int n, m, i, j;
Scanner ent = new Scanner (System.in);
System.out.println("Digite o valor de m:");
m = ent.nextInt();
System.out.println("Digite o valor de n:");
n = ent.nextInt();
int [] v = new int [m];
for (i=0; i<m; i++) {
v[i] = i;
}