php编写两个32位以上数字相加

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title></title>
</head>
<?php
    if($_GET){
        $name1= $_GET['name1'];
        $name2= $_GET['name2'];
        $arr1 = str_split($name1);
        $arr2 = str_split($name2);
        $cou1 = count($arr1);
        $cou2 = count($arr2);
        $count = $cou1>=$cou2?$cou1:$cou2;
        $sarr = array();
        for($i=1;$i<=$count+1;$i++){
            if($cou1-$i>=0){
                $a = $arr1[$cou1-$i];
            }else{
                $a = 0;
            }
            if($cou2-$i>=0){
                $b = $arr2[$cou2-$i];
            }else{
                $b = 0;
            }
            if(isset($sarr[$count-$i])){
                $d = $sarr[$count-$i];
            }else{
                $d = 0;
            }
            $c = $a+$b+$d;
            if($c>=10){
                $carr = str_split($c.'');
                $arr[$count-$i] = $carr[1];
                $sarr[$count-$i-1] = $carr[0];
            }else{
                $arr[$count-$i] = $c;
            }
        }
        ksort($arr);
        $zong = implode('',$arr);
        if(substr($zong,0,1) == 0){
            $zong = substr($zong,1);
        }
        echo $zong;
    }
?>
<body class="vdbg">
    <form action="" method="get">
    <input type="text" name="name1" value=""/>
    <input type="text" name="name2" value=""/>
    <input type="submit" name="submit" value="提交"/>
    </form>
</body>
<?php
echo '<br/>';
function test_odd($var){
    return($var & 8);
}
$a = array('a','b',2,3,4,5,6,7,8,9,11);
print_r(array_filter($a,"test_odd"));
echo '<br/>';
$b = array('b',1,12,2,3,4);
$c = array('a','b',2,6,7,8);
print_r(array_intersect($a,$b,$c));
?>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值