- 博客(34)
- 收藏
- 关注
转载 匿名函数
class A{ public $base = 100; public function __construct() { echo "a-->construct"; }}class B{ private $base = 1000; public function __constru...
2018-01-11 14:56:00
143
转载 session存入redis
本地文件存储无法解决集群中的session共享问题。。。所以,,,1,PHP的sessionPHP的session本身就支持存入file,redis,memcache.修改php.ini或者直接在项目的index.php中间设置ini_set('session.save_handler', 'redis');ini_set('session.save_pat...
2017-10-12 13:35:00
169
转载 存储过程(二)
更确切的说,是用存储过程对比myisam和innodb的写入效率;1,创建两张表create table testmyisam( id int unsigned primary key auto_increment, `name` varchar(20) not null )engine=myisam;create table testinnodb(...
2017-10-11 15:03:00
165
转载 二叉排序
二叉排序,附带插入,查找和删除值。。/* Author: buer Date: 2017/9/18 11:56:02*/#include <stdio.h>#include <stdlib.h>typedef struct Tree{ int data; struct Tree *lchil...
2017-09-18 22:14:00
124
转载 最短路径(弗洛伊德算法)
假设条件同上。。整个算法最核心的,个人觉得就是一个公式:weight[a][b] = min{weight[a][b], weight[a][c]+weight[c][b]}即,从一点到另外一点的最短距离,是在直线和经过一个中间点的‘绕路’距离之间求最短。。然后利用上一次的结果迭代。。/** author: buer* github: buer0.gith...
2017-09-09 07:54:00
162
转载 最短路径(迪杰斯特拉算法)
假定条件和上一篇相同。。。其实算法思路和上一篇也相同,均为贪心算法。。。/** author: buer* github: buer0.github.com*/#include <stdio.h>#include <stdlib.h>#define MAXSIZE 10typedef struct Graph...
2017-09-08 22:40:00
103
转载 生成最小树(普里姆算法)
普利姆算法生成最小树,当两个节点之间没有边时,权值为65535,结点与自身之间为0.。。。#define MAXSIZE 10typedef struct Graph{ int table[MAXSIZE][MAXSIZE]; int num;}Graph;void createTable(Graph *graph);void ...
2017-09-07 21:51:00
305
转载 广度优先遍历
额。。一到五个结点就报错。。。重要的是我调试的时候,他竟然就正常了。。。。typedef struct{ int **table; int num;}Graph; typedef struct Queue{ int data; struct Queue *next;}Queue;void create...
2017-09-03 17:38:00
93
转载 马踏棋盘算法(骑士周游列国)
由于用的是效率比较低的枚举,为了避免程序运行时间太长,这里就改为6*6的棋盘你也可以将宏定义中间的X和Y改为你想要的长和宽。。/** author: buer* github: buer0.github.com*/#include <stdio.h>#include <stdlib.h>#define X 6 //定...
2017-09-01 10:59:00
217
转载 二叉树添加索引
前序遍历创建,前序打印。。。中序遍历添加索引,再循环打印。。。typedef struct BiNode{ char data; char ltag, rtag; struct BiNode *lchild, *rchild;}BiNode;void createTree(BiNode **root);void printTree...
2017-08-22 21:49:00
177
转载 杨辉三角
哦。。曾经的痛。。。。<?php $arr = [1];for ($i=0; $i < 10 ; $i++) { for ($j=0; $j < count($arr); $j++) { echo $arr[$j]; echo " "; } echo "<br>...
2017-08-19 11:13:00
91
转载 KMP算法
字符串匹配,失败时回溯。。void getNext(char needle[], int next[]);int kmp(char needle[], char haystack[], int next[]);int main(){ char needle[255] = {'\0'}; char haystack[255] = {'\0'};...
2017-08-19 10:22:00
84
转载 八皇后问题
经典的八皇后问题。。#define LEN 8int count = 0;void eightQueen(int chess[][8], int row);int isSafe(int chess[][8], int row, int col);int main(int argc, char *argv[]){ int chess...
2017-08-18 06:58:00
84
转载 生成逆波兰表达式
#define MAXSIZE 10typedef struct OpNode{ char data; struct OpNode *next;}OpNode;typedef struct OpStack{ OpNode *top;}OpStack;void op_pop(OpStack *s, char ...
2017-08-15 22:13:00
111
转载 逆波兰表达式
以输入正确的逆波兰表达式为前提,计算结果。。。#define MAXSIZE 10typedef struct Node{ double data; struct Node *next;}Node;typedef struct Stack{ Node *top;}Stack;void s_push(Stack *...
2017-08-14 17:36:00
103
转载 简单的入栈出栈
简单的入栈和出栈操作。。。#define MAXSIZE 26typedef char ElemType;typedef struct Stack{ ElemType *base; ElemType *top; int stackSize;}Stack;void stack_init(Stack *s);void st...
2017-08-14 15:55:00
107
转载 从指定位置开始输出
输入1,则跳过第一个从第二个开始输出,输入-1,则把最后一个放在最前面,然后开始输出。。。#define LIST "ABCDEFGHIJKLMNOPQRSTUVWXYZ"typedef struct DulNode{ char data; struct DulNode *prior; struct DulNode *next; }...
2017-08-12 22:38:00
198
转载 魔术师发牌问题
就是有一堆牌,先跳过零张,翻出第一张为一,然后跳过一张,翻出第二张为2。。。。被跳过的牌放在最下面。。。。typedef struct Node{ int data; struct Node *next;}Node;void circle_init(Node *head, const int len);void circle_set(N...
2017-08-12 15:35:00
117
转载 约瑟夫问题
额,直接上代码:typedef struct Node{ int data; struct Node *next;}Node;void circle_init(Node *head, const int len);void circle_kill(Node *head, int num, const int len);void circ...
2017-08-12 14:58:00
86
转载 快慢指针查找未知长度单链表中间值
快慢指针查找位置长度的单链表的中间值。。。。根据步长不同,也可以用来查找三分之一处,四分之一处。。。。。。typedef struct List{ int data; struct List * next;}List;void list_init(List *head, const int len);void search(List *...
2017-08-11 15:43:00
118
转载 数组单链表
在那个久远的没有指针的年代,,据说伟大的先人们都是用数组来实现单链表#define MAXSIZE 20typedef struct{ int cursor; int data;}Component;void cursor_init(Component list[], int *len){ int i = 0; ...
2017-08-10 18:01:00
125
转载 类型约束
昨天写序列的时候,为了约束参数类型为string,就写了下面这段代码function createNext(string $pre, $elem = '', $count = 0){ // } 我本意是想限定$pre一定要是string,但是当我真的传了一个string过来的时候,却报了如下错:Argument 1 passed t...
2017-08-09 15:35:00
159
转载 记录两个算法
第一个,生成look-and-say sequencefunction createNext($pre, $elem = '', $count = 0){ $len = strlen($pre); $string = ''; $a = substr($pre, 0,1); if($elem == $a) { $count += 1; }else {...
2017-08-08 19:19:00
76
转载 反射api获取源代码
使用反射 api获取类或者类中方法的源代码class ReflectionUtil{ public static function getClassSource(ReflectionClass $reflection) { $file = $reflection->getFileName(); $lines = file($file); $st...
2017-08-08 10:34:00
125
转载 laravel中model字段的类型定义
在HasAttributes中的两段方法:public function setAttribute($key, $value) { // First we will check for the presence of a mutator for the set operation // which simply lets the de...
2017-07-05 17:01:00
1496
转载 利用回掉函数增强可扩展性
<?php class Listener{ public static function handle() { static $count = 0; return function(Event $event) use ($count) { echo "eventName=" . $event->name . " and count...
2017-06-06 18:56:00
73
转载 存储过程
1,什么是MySQL存储过程个人的理解就是一组编译好的用于完成指定操作的sql语句。一般sql语句是每执行一次编译一次,存储过程则只编译一次,之后都可以直接使用。用于提高速度,降低复杂度。2,使用举个栗子:CREATE PROCEDURE Get_Data( IN id int)SELECT * FROM users WHERE id = @id;SET @p0...
2017-06-06 16:56:00
88
转载 直接调用魔术方法
看laravel的包文件时,无意中发现他引入了一个专门实例化一个类而又不触发构造方法的包。"name": "doctrine/instantiator", "description": "A small, lightweight utility to instantiate objects in PHP without invoking their construc...
2017-05-16 11:19:00
95
转载 简单实现laravel中的装饰者模式
直接上浓缩版的代码<?phpinterface Step{ public static function go(Closure $next);}/*** */class FirstStep implements Step{ public static function go(Closure $next) { echo "开启session,获取数据&l...
2017-04-14 17:24:00
143
转载 jquery实现简单懒加载
话不多说,直接上代码。<img class="lazy" data-src="/images/example.png" src="/images/placeholder.png">$(function() { $('.lazy').each(function() { $(this).attr('src', $(this).data('src')); ...
2017-04-14 11:21:00
63
转载 简单理解laravel中的Ioc控制反转(依赖注入)
由于laravel中的Ioc还考虑了参数为字符串,参数有默认值等众多情况,所以总体看起来比较复杂。但总之,其目的是为了解决不同类之间的依赖关系。当然工厂方法某种程度上也能解决这个问题,只是,Ioc来的更优雅。这里提供一个删节版<?php /*** */class Container{ protected $bindings = [];...
2017-04-13 15:51:00
233
转载 insteadof
在php手册中间搜索insteadof是没有结果的。insteadof主要是用来解决在同一个类中同时使用多个trait,然而在使用的这些trait中方法名称冲突的问题。借用别人的例子:<?phpclass Base{ public function hello() { echo 'method hello from class Base' . '&...
2017-04-11 16:55:00
337
转载 反射api
<?phpclass A{ public function call() { echo "hello world"; }}$ref = new ReflectionClass('A');$inst = $ref->newInstanceArgs();$inst->call();输出: hello world...
2017-04-10 18:38:00
78
转载 第一篇
有自己的博客啦~~~发篇文章看看效果!多写博客,多记开发过程中的坑坑洼洼转载于:https://www.cnblogs.com/buerr/p/6165458.html
2016-12-12 18:01:00
75
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人