摘要: 判断数组是不是正序 自己写的粗糙算法: 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.狂人 阅读(389) 评论(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.狂人 阅读(247) 评论(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.狂人 阅读(357) 评论(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.狂人 阅读(1185) 评论(3) 推荐(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:46 IT.狂人 阅读(91) 评论(0) 推荐(0) 编辑
摘要: 一、文件格式 1. 对于只含有 php 代码的文件,我们将在文件结尾处忽略掉 "?>" 。这是为了防止多余的空格或者其它字符影响到代码。 例如: <?php $foo = 'foo'; 2. 缩进应该能够反映出代码的逻辑结果,尽量使用四个空格,禁止使用制表符TAB,因为这样能够保证有跨客户端编程器软 阅读全文
posted @ 2018-09-09 08:42 IT.狂人 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 1 能用内置函数写的 不要自己写 效率低 2 内置函数也有快与慢之分 3 尽可能少使用魔法函数 4 @错误抑制符 会产生额外开销 尽量使用try..throw方式 5 合理使用内存 unset掉不用的内存 6 尽量少使用正则表达式 正则使用回溯,性能低(但是写的好的话没问题) 7 避免在循环内做运算 阅读全文
posted @ 2018-09-09 08:36 IT.狂人 阅读(101) 评论(0) 推荐(0) 编辑