Permutations: Difference between revisions
Content added Content deleted
Line 3,500: | Line 3,500: | ||
<lang php> |
<lang php> |
||
//Author Gavryushin Ivan @dcc0 |
//Author Gavryushin Ivan @dcc0 |
||
<?php |
|||
$b=" |
$b="0123456"; |
||
$a=strrev($b); |
$a=strrev($b); |
||
print_r($a); |
|||
⚫ | |||
while ($a !=$b) { |
while ($a !=$b) { |
||
$i=1; |
$i=1; |
||
while($a[$i] > $a[$i-1]) { |
while($a[$i] > $a[$i-1]) { |
||
$i++; |
$i++; |
||
} |
} |
||
$j=0; |
$j=0; |
||
while($a[$j] < $a[$i]) { |
while($a[$j] < $a[$i]) { |
||
⚫ | |||
$j++; |
$j++; |
||
} |
} |
||
Line 3,518: | Line 3,517: | ||
$a[$j]=$a[$i]; |
$a[$j]=$a[$i]; |
||
$a[$i]=$c; |
$a[$i]=$c; |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
$y=substr($a, $i); |
|||
$a=$x.$y; |
|||
print '<br/>'; |
|||
} |
|||
⚫ | |||
?> |
|||
⚫ | |||
'''Output''' |
'''Output''' |
||
<pre> |
<pre> |