随笔分类 -  PHP练习册

摘要:判断数组是不是正序 自己写的粗糙算法: function in_asc_order($arr) { // Program your algorithm here to be tested $arr_length = count($arr); if($arr_length==0){ return 0; 阅读全文
posted @ 2018-09-09 08:52 IT.狂人 阅读(397) 评论(0) 推荐(0)
摘要:10进制转成2进制 然后相加 function countNumber( $number) { $sum = 0; while ($number!=0){ if($number%2 != 0 ){ $sum++; } $number = $number/2; } return $sum; } 阅读全文
posted @ 2018-09-09 08:51 IT.狂人 阅读(255) 评论(0) 推荐(0)
摘要:介绍 ABC 返回每个字符的ascii A->65 B->66 C->77 组成656667 把所有的7替换成1 然后变成 656667 和 656661 每个数值做加法 然后做减法 (6 + 5 + 6 + 6 + 6 + 7) - (6 + 5 + 6 + 6 + 6 + 1) 6 自己写的: 阅读全文
posted @ 2018-09-09 08:49 IT.狂人 阅读(368) 评论(0) 推荐(0)
摘要:一维数组求平均值 function median($a) { // Work your magic here. Make sure you're calculating the median, NOT the mean! return array_sum($a)/count($a); } 阅读全文
posted @ 2018-09-09 08:48 IT.狂人 阅读(1238) 评论(3) 推荐(0)