fork download
  1. using System;
  2.  
  3. namespace POdzbiory
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int t = int.Parse(Console.ReadLine());
  10. for (int i = 0; i < t; i++)
  11. {
  12. string[] input = Console.ReadLine().Split();
  13. int n = int.Parse(input[0]);
  14. int k = int.Parse(input[1]);
  15. int[] tab = new int[k];
  16. for (int j = 0; j < k; j++)
  17. {
  18. tab[j] = j + 1;
  19. }
  20. while (true)
  21. {
  22. for (int j = 0; j < k; j++)
  23. {
  24. Console.Write(tab[j] + " ");
  25. }
  26. Console.WriteLine();
  27. int l = k - 1;
  28. while (l >= 0 && tab[l] == n - k + l + 1)
  29. {
  30. l--;
  31. }
  32. if (l < 0)
  33. {
  34. break;
  35. }
  36. tab[l]++;
  37. for (int j = l + 1; j < k; j++)
  38. {
  39. tab[j] = tab[j - 1] + 1;
  40. }
  41. }
  42. Console.WriteLine();
  43. }
  44. }
  45. }
  46. }
Success #stdin #stdout 0.05s 32292KB
stdin
2
3 3
5 2
stdout
1 2 3 

1 2 
1 3 
1 4 
1 5 
2 3 
2 4 
2 5 
3 4 
3 5 
4 5