想了半天,自己的过程有问题,呵呵,循环错了,正在做一个在线考试的东西
如果有人需要的话:<?
$choice[10];
for ($i=1;$i<=10;$i++)
{
$choice[$i]=0;
echo $choice[$i];
}
echo "<br>";
/*
for ($k=1;$k<=10;$k++)
{
$tmp=rand(1,20);
while(check_single($tmp))
{
$choice[$k]=$tmp;
}
}
*/
for ($k=1;$k<=10;$k++)
{
$tmp=rand(1,20);
save_single();
} function check_single($tmp)
{
global $tmp,$choice;
for ($j=1;$j<=10;$j++)
{
if ($choice[$j]==$tmp)
{
return false;
}
}
return true;
}function save_single()
{
global $tmp,$choice,$k;
if(check_single($tmp))
{
$choice[$k]=$tmp;
}
else
{
$tmp=rand(1,20);
save_single();
}
}for ($n=1;$n<=10;$n++)
{
echo $choice[$n]."-";
}?>
如果有人需要的话:<?
$choice[10];
for ($i=1;$i<=10;$i++)
{
$choice[$i]=0;
echo $choice[$i];
}
echo "<br>";
/*
for ($k=1;$k<=10;$k++)
{
$tmp=rand(1,20);
while(check_single($tmp))
{
$choice[$k]=$tmp;
}
}
*/
for ($k=1;$k<=10;$k++)
{
$tmp=rand(1,20);
save_single();
} function check_single($tmp)
{
global $tmp,$choice;
for ($j=1;$j<=10;$j++)
{
if ($choice[$j]==$tmp)
{
return false;
}
}
return true;
}function save_single()
{
global $tmp,$choice,$k;
if(check_single($tmp))
{
$choice[$k]=$tmp;
}
else
{
$tmp=rand(1,20);
save_single();
}
}for ($n=1;$n<=10;$n++)
{
echo $choice[$n]."-";
}?>
是这句嘛?我的原来怎么在win2k下是正常的,linux下不正常?
跟你反了?还是我记错了 :)
可能特累,你看zxyufan(宇凡)现在加班呢,而我是值班,多......
java好玩么?跟c++一样难吧?