107
 правок
Изменения
Нет описания правки
* Вместо <tex>1</tex> записываем <tex>0</tex> 
* Дописываем максимально возможный хвост из единиц
 '''int[]''' nextVectorprevVector('''int[]''' a): <font color=green>// <tex>n</tex> {{---}} длина вектора</font>
   '''while''' (n >= 0) '''and''' (a[n] != 1)
     a[n] = 1
* Перевернем правую часть
 '''int[]''' nextPermutationprevPermutation('''int[]''' a): <font color=green>// <tex>n</tex> {{---}} длина перестановки</font>
   '''for''' i = n - 2 '''downto''' 0
     '''if''' a[i] > a[i + 1]
* Перевернем правую часть
 '''int[]''' nextPermutationprevMultipermutation('''int[]''' a): <font color=green>// <tex>n</tex> {{---}} длина перестановки</font>
   '''for''' i = n - 2 '''downto''' 0
     '''if''' a[i] > a[i + 1]
Пусть массив <tex>a</tex> хранит сочетания, так что первый элемент хранится в <tex>a[1]</tex>
 int[] nextChooseprevChoose('''int[]''' a): <font color=green>// <tex>n</tex> {{---}} количество различных элементов</font>
   a[0] = 0                       <font color=green>// <tex>k</tex> {{---}} длина сочетания</font>
   for i = k downto 1
