2010年3月21日

摘要: <?php$myarr=array(100,200,300,400,500);functionmysort($arr){$num=count($arr);for($i=0;$i<$num;$i++){for($j=0;$j<$num-$i;$j++){if($arr[$j]<$arr[$j+1]){$tmp=$arr[$j];$arr[$j]=$arr[$j+1];$arr... 阅读全文
posted @ 2010-03-21 08:37 fancing 阅读(171) 评论(0) 推荐(0) 编辑
摘要: <?phpclassstack{private$top;private$base;private$myArr=array();function__construct(){$this->top=-1;$this->base=-1;}functionpush($e){$this->top++;$this->myArr[$this->top]=$e;}function... 阅读全文
posted @ 2010-03-21 08:36 fancing 阅读(266) 评论(0) 推荐(0) 编辑
摘要: <?phpfunctionp($myArr,$low,$high){$key=$myArr[$low];while($low<$high){while($low<$high&amp;&amp;$key<=$myArr[$high]){$high--;}$tmp=$myArr[$low];$myArr[$low]=$myArr[$high];$myArr[$h... 阅读全文
posted @ 2010-03-21 08:36 fancing 阅读(221) 评论(0) 推荐(0) 编辑
摘要: 简单的用php实现了汉诺塔问题的求解,使用递归调用,但是用php实现要是盘子的个数很多的话,运行起来会很慢的...汉诺塔主要是有三个塔座X,Y,Z,要求将三个大小不同,依小到大编号为1,2.....n的圆盘从A移动到塔座Z上,要求(1):每次只能移动一个圆盘(2):圆盘可以插到X,Y,Z中任一塔座上(3):任何时候不能将一个较大的圆盘压在较小的圆盘之上主要是运用了递归的思想,这里使用php做个简单... 阅读全文
posted @ 2010-03-21 08:35 fancing 阅读(1355) 评论(0) 推荐(0) 编辑
摘要: 要实现无限级分类,递归一般是第一个也是最容易想到的,但是递归一般被认为占用资源的方法,所以很多系统是不考虑使用递归的本文还是通过数据库的设计,用一句sql语句实现数据库字段大概如下:-----------------------------------------------------------------------------------id 编号fid 父分类编号class_name 分... 阅读全文
posted @ 2010-03-21 08:34 fancing 阅读(646) 评论(0) 推荐(0) 编辑
摘要: 今天尝试玩玩url规则重写,用sablog1.6作了测试首先要打开rewrite_module,这个在apache的httpd.conf文件中修改,去掉其注释LoadModule rewrite_module modules/mod_rewrite.so然后遇到的一个问题是如何建立.htaccess文件,windows是不能建立这样的没有文件名的文件的后来找到了一个办法,可以先建立一个htacce... 阅读全文
posted @ 2010-03-21 08:33 fancing 阅读(223) 评论(0) 推荐(0) 编辑
摘要: <?php$host="localhost";$user="root";$password="123456";$dbname="nbs";mysql_connect($host,$user,$password);mysql_select_db($dbname);$mysql="setcharsetutf8;\r\n";$q1=mysql_query("showtables");while($... 阅读全文
posted @ 2010-03-21 08:33 fancing 阅读(300) 评论(0) 推荐(0) 编辑
摘要: <?phpfunctiondatatosql($table){global$db;$tabledump="DROPTABLEIFEXISTS$table;\n";$createtable=$db->query("SHOWCREATETABLE$table");$create=$db->fetch_array($createtable);$tabledump.=$create[1]... 阅读全文
posted @ 2010-03-21 08:32 fancing 阅读(170) 评论(0) 推荐(0) 编辑
摘要: <?phpfunctioninsertion_sort(array$anArr){for($i=1;$i<count($anArr);$i++){$dump=$anArr[$i];$j=$i;while($j>0&amp;&amp;$dump<$anArr[$j-1]){$anArr[$j]=$anArr[$j-1];$j=$j-1;if($j<0){... 阅读全文
posted @ 2010-03-21 08:31 fancing 阅读(132) 评论(0) 推荐(0) 编辑
摘要: <?phpfunctionselection_sort(array$anArr){for($i=0;$i<count($anArr);$i++){$s=$i;for($j=$i+1;$j<count($anArr);$j++){if($anArr[$j]<$anArr[$s]){$s=$j;}}swap($anArr[$i],$anArr[$s]);}return$anAr... 阅读全文
posted @ 2010-03-21 08:31 fancing 阅读(108) 评论(0) 推荐(0) 编辑