List contains all 7-variations

I’m practicing programming by doing a little lotto calculator to compute lotto designs. In C++, how can I make a list that contains all different lotto rows i.e. seven numbers from the set {1,2,…,39}? Name, I’m hoping to find an algorithm to automatize the following:

  list<int> L;
  L.push_front(1);     
  L.push_front(2);
  L.push_front(3);     
  L.push_front(4);  
  L.push_front(5);     
  L.push_front(6);
  L.push_front(7); 

  L.push_front(1);     
  L.push_front(2);
  L.push_front(3);     
  L.push_front(4);  
  L.push_front(5);     
  L.push_front(6);
  L.push_front(8);  
  ...
  L.push_front(33);     
  L.push_front(34);  
  L.push_front(35);     
  L.push_front(36);
  L.push_front(37);
  L.push_front(38);
  L.push_front(39);  

I thought that a recursion might work to generate all combinations, in pseudocode like
K({1,2,…,39},7)=(1,K({2,3,…,39},6)) union (2,K({1,3,…,39},6))
but the problem is that functions can’t return arrays in C++.

Do you need all combinations ? Or like Lotto just find out 7 Lucky numbers.If you want to choose 7 out of 49 it’s 85900584 combinations.

So , I’m guessing you need 7 lucky numbers.

list L;
for(int i=0;i<7;i++){
	luckyNumber = rand() % 49 + 1;
	if(!checkDuplicates){             //I don't know if you can draw duplicates
		L.push_front(luckyNumber);        //If not just implement that
	}
	else{
		i--;
	}
}

No. I need all 7-variations. And the maximum value is 39, not 49.