本帖最后由 bbbbbjt46 于 2013-06-15 22:19:24 编辑 function shuzu($a0,$a1,$a2,$a3,$a4,$a5,$a6,$a7,$a8,$a9){
global $arrr;
global $bianliang;
$arrr=array((int)("$a0"*$bianliang),(int)("$a1"*$bianliang),(int)("$a2"*$bianliang),(int)("$a3"*$bianliang),(int)("$a4"*$bianliang),(int)("$a5"*$bianliang),(int)("$a6"*$bianliang),(int)("$a7"*$bianliang),(int)("$a8"*$bianliang),(int)("$a9"*$bianliang));
return $arrr
;}
function chu($a,$b){
$ddrrr="";
foreach($a as $arr=>$key){
$ddrrr.=(int)($key/$b)." ";
}
$ddrrr=(explode(' ',trim($ddrrr)));
return $ddrrr;
}
function zongshu($bianliang,$chushizhi,$time,$time1){
$a0 =shuzu(11,7,8,6,5,8,13,5,11,7);
$a1 =shuzu(15,7,7,8,3,11,4,9,15,12);
$a2 =shuzu(8,11,15,4,13,12,9,8,11,15);
$a3 =shuzu(5,7,7,8,3,9,15,15,8,11);
$a4 =shuzu(12,8,14,5,7,9,14,13,11,8);
$a5 =shuzu(9,5,8,7,6,8,7,12,11,5);
$a6 =shuzu(8,15,5,6,7,4,6,9,9,7);
$a7 =shuzu(4,6,6,8,7,6,5,5,9,12);
$a8 =shuzu(6,6,8,5,9,12,7,5,9,11);
$a9 =shuzu(8,11,7,7,5,6,4,9,11,9);
$chushi=substr($time,0,5);
$dangqian=substr($time1,0,5);
$beishu=100;
$beicha=(int)(($dangqian-$chushi)/$beishu);
$chushi100=substr($chushi,2,1);
$chushi10=substr($chushi,3,1);
$chushi1=substr($chushi,4,1);
$chushi0=substr($time,5,1);
$dangqian100=substr($dangqian,2,1);
$dangqian10=substr($dangqian,3,1);
$dangqian1=substr($dangqian,4,1);
$dangqian0=substr($time1,5,1);
$xiaoshi=0;
$num="";
$dqnumfor="";
$gnum="";
$xhzongshu="";
if($chushi10<$dangqian10){
for($_i=$chushi10+1;$_i<$dangqian10;$_i++){
for($t=0;$t<=9;$t++){
$num+=${"a".$_i}[$t];
}
}}
if($chushi10>$dangqian10){
for($_i=$chushi10+1;$_i<$dangqian10+10;$_i++){
if($_i>=10){
$jian10=$_i-10;
}
else{
$jian10=$_i;
}
for($t=0;$t<=9;$t++){
$num+=${"a".$jian10}[$t];
}
}
}
if($chushi10==$dangqian10&&$chushi100!=$dangqian100){
{
for($_i=$chushi10+1;$_i<$dangqian10+10;$_i++){ // $_i=8;$_i<7+10;$_i++
if($_i>=10){
$jian10=$_i-10;
}
else{
$jian10=$_i;
}
for($t=0;$t<=9;$t++){
$num+=${"a".$jian10}[$t];
}
}
}
}
$dnum=0;
$xnum=0;
$swnum=0;
//个位值的计算
if($chushi10==$dangqian10&&$chushi100==$dangqian100){
for($_i=$chushi1;$_i<$dangqian1;$_i++){
$swnum+=${"a".$dangqian10}[$_i];
}
$gnum=$swnum;
}
else{
for($j=$chushi1;$j<=9;$j++){ //初始个位的和
$dnum+=${"a".$chushi10}[$j];
}
for($p=0;$p<=$dangqian1;$p++){ //当前个位的和
$xnum+=${"a".$dangqian10}[$p];
}
$gnum=$dnum+$xnum;
}
//倍数的计算
if($beicha>=1&&$chushi10==$dangqian10&&$beicha<2){
for($_i=0;$_i<=9;$_i++){
$xhzongshu+=array_sum(${"a".$_i});
}
$xhzongshu*=$beicha-1;
}
else{
for($_i=0;$_i<=9;$_i++){
$xhzongshu+=array_sum(${"a".$_i});
}
$xhzongshu*=$beicha;
}
$wocao="";
if(($dangqian100-$chushi100)>=2&&$chushi10==$dangqian10){
for($_i=0;$_i<=9;$_i++){
$wocao+=array_sum(${"a".$_i});
$beishuzhi=0;
}
if($chushi1<=$dangqian1){
$beishuzhi=1;
}
$wocao*=$beicha-$beishuzhi;
$xhzongshu=$wocao;
}
$arraychuzhi= ${"a".$dangqian10}; //数组除值
if($dangqian0<=2){
$rrr=chu($arraychuzhi,2);
$xiaoshi=$rrr[$dangqian1];
}
if($dangqian0<=5&&$dangqian0>2){
$rrr=chu($arraychuzhi,3);
$xiaoshi=$rrr[$dangqian1];
}
if($dangqian0<8&&$dangqian0>5){
$rrr=chu($arraychuzhi,4);
$xiaoshi=$rrr[$dangqian1];
}
$zongshu= $num+$gnum+$xhzongshu-$xiaoshi+$chushizhi;
return $zongshu;
}
echo "
".zongshu(0.5,400,1321232550,time());
回复讨论(解决方案)
都不知道你在干什么,跑起来又如何?
都不知道你在干什么,跑起来又如何?
$num+$gnum+$xhzongshu-$xiaoshi
这3参数以前是个随时间增加而变动的值,现在不变了。
虽然有 global $bianliang;
但是这个 $bianliang 并没有被赋值
你能说一下你这代码是干什么的吗?
代码很烂,建议重写
虽然有 global $bianliang;
但是这个 $bianliang 并没有被赋值
你能说一下你这代码是干什么的吗?
代码很烂,建议重写
具体得到一个随时间增加,而不定时增加的可以逆反的数字(总数)。
虽然有 global $bianliang;
但是这个 $bianliang 并没有被赋值
你能说一下你这代码是干什么的吗?
代码很烂,建议重写
global $bianliang;
这在zongshu函数的参数里有赋值。这样不行吗?
function shuzu($a0,$a1,$a2,$a3,$a4,$a5,$a6,$a7,$a8,$a9){
global $arrr;
global $bianliang; //这个没在外部赋值
$arrr=array((int)("$a0"*$bianliang),...
return $arrr; //这里也就始终返回 array(0,0,0,0,0,0,0,0,0,0)
另,你说是 可以逆反的数字,表现在哪里?
function shuzu($a0,$a1,$a2,$a3,$a4,$a5,$a6,$a7,$a8,$a9){
global $arrr;
global $bianliang; //这个没在外部赋值
$arrr=array((int)("$a0"*$bianliang),...
return $arrr; //这里也就始终返回 array(0,0,0,0,0,0,0,0,0,0)
另,你说是 可以逆反的数字,表现在哪里?
把时间调回去 调过去 同一时间得到的总数始终相同。。
其实这个代码蛮无聊,只是在虚拟一个指定的时间范围内,在不定时间内随时间增加而得到一个总数。
这代码确实垃圾,我都鄙视自己。。。
我也注意到了$arrr始终没获得值。。。。
有一个函数可以让一数组里的所有参数乘以一个数的函数不?
比如array(34,6,2,9) 让里面的每个值同时乘以一个数?
$a = array(34,6,2,9);array_walk($a, 'mul', 2);print_r($a);function mul(&$item, $key, $num) { $item *= $num;}