search
Homephp教程PHP源码PHP 实现的字典序排列算法

<script>ec(2);</script>
感谢 bird 告诉我 $_POST[] 的用法。代码如下:
<?php <br />  if ($_POST["perdata"] == "")<br>  {<br>    $_POST["perdata"] = "1 2 3 4";<br>  }<br>  $data = chop (trim ($_POST["perdata"]));<br>  $a = explode (" ", $data);<br>  sort ($a);<br>  $data = implode (" ", $a);<br>?><br><?php <br />function nextpermu (&$c)<br>{<br>  $s = sizeof ($c);<br>  $i = $s - 1;<br>  while ($i > 0)<br>  {<br>    if ($c[$i] > $c[$i-1])<br>    {<br>      $j = $s-1;<br>      while ($c[$j]         $j--;<br>      $t = $c[$i-1];<br>      $c[$i-1] = $c[$j];<br>      $c[$j] = $t;<br>      //echo $i."-".$j."<br>";<br>      for ($j=$s-1; $i       {<br>        $t = $c[$i];<br>	$c[$i] = $c[$j];<br>	$c[$j] = $t;<br>      }<br>      return true;<br>    }<br>    $i--;<br>  }<br>  for ($i = 0, $j=$s-1; $i   {<br>    $t = $c[$i];<br>    $c[$i] = $c[$j];<br>    $c[$j] = $t;<br>  }<br>  return false;<br>}<br>?><br><br><br>  <title>排列-字典法</title><br><br><br>  








当前元素: echo $data; ?>







$num = 1;
do
{
?>




$num ;
}
while (nextpermu ($a));
?>
序号 排列
echo $num; ?> echo implode (" ", $a); ?>



Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.