自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

  • 博客(73)
  • 收藏
  • 关注

转载 php 判断一个点是否在一个多边形区域内

<?phpclass pointMap{ private static $coordArray; private static $vertx = []; private static $verty = []; public static function setArray(array $Array) { self::$coordArr...

2017-10-26 12:22:00 583

转载 PHP 如何在txt里查找包含某个字符串的那一行?

<?php$handler=fopen("1.txt","r");while(!feof($handler)){$m = fgets($handler,4096); //fgets逐行读取,4096最大长度,默认为1024if(substr_count($m,"百度")>0) //查找字符串{print_r($m); //打印结果}...

2017-09-19 19:09:00 1212

转载 php 实现栈与队列

<?phpclass queueOp{ /* * 队尾入队 * Return:处理之后队列的元素个数 */ public function tailEnquque($arr,$val){ return array_push($arr,$val); } /* * 队尾出队 ...

2017-09-09 13:36:00 169

转载 微信支付 接口

controler<?php/** * @name WxPayController * @author pangee * @desc 微信支付功能封装 */$qrcodeLibPath = dirname(__FILE__).'/../library/ThirdParty/Qrcode/';include_once( $qrcodeLibPa...

2017-09-02 15:43:00 268

转载 文章添加,删除,修改,分页列表

Art:<?php/** * @name UserController * @author pangee * @desc 用户控制器 */class ArtController extends Yaf_Controller_Abstract { public function indexAction() { return $this-&...

2017-09-02 09:28:00 117

转载 用户注册,登录API 接口

Controer:<?php/** * @name UserController * @author pangee * @desc 用户控制器 */class UserController extends Yaf_Controller_Abstract { public function indexAction() { return $...

2017-09-01 10:26:00 1722

转载 centos php环境搭建

CentOS6.5系统安装配置LAMP(Apache+PHP5+MySQL)服务器环境准备篇:1、配置防火墙,开启80端口、3306端口vi /etc/sysconfig/iptables-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT #允许80端口通过防火墙-A INPUT -m state -...

2017-08-30 17:21:00 78

转载 php字符串 函数

strtolower()//字符串转化小写的字母$str="abcdEfG";$s=strtolower($str);输出:abcdefg;strtoupper();字符串转化大写的字母$str="abcdEfG";$s=strtoupper($str);输出:ABCDEFGltrim//除去左边的空格$str=" abcdEfG D";$result=lt...

2017-08-24 14:40:00 89

转载 php 数组函数

排序: sort() 函数用于对数组单元从低到高进行排序。  rsort() 函数用于对数组单元从高到低进行排序。  asort() 函数用于对数组单元从低到高进行排序并保持索引关系。  arsort() 函数用于对数组单元从高到低进行排序并保持索引关系。  ksort() 函数用于对数组单元按照键名从低到高进行排序。  krsort() 函数用于对数组单元按照键名从高到低进...

2017-08-24 14:21:00 45

转载 github 上传项目

注册账户以及创建仓库 要想使用github第一步当然是注册github账号了。之后就可以创建仓库了(免费用户只能建公共仓库),Create a New Repository,填好名称后Create,之后会出现一些仓库的配置信息,这也是一个Git的简单教程。步骤如下:打开https://github.com直接在首页上注册点按钮注册成功...

2017-08-02 17:23:00 64

转载 PHP 基础

PHP 基础//实现中文字串截取无乱码的方法 // header("Content-Type:text/html;charset=utf-8"); // function substr_utf8($str,$start,$lenght=null){ // return join("",array_sli...

2017-07-27 11:20:00 89

转载 配置本地域名

Ubuntu php环境sudo add-apt-repository ppa:ondrej/phpsudo apt-get updatesudo apt-get install php5.6http://www.linuxidc.com/Linux/2016-01/127180.htm  1.配置本地域名 1.host文件 C:\Windows\...

2017-07-26 20:25:00 93

转载 偶串

如果一个字符串由两个相同字符串连接而成,就称这个字符串是偶串。例如"xyzxyz"和"aaaaaa"是偶串,但是"ababab"和"xyzxy"却不是。牛牛现在给你一个只包含小写字母的偶串s,你可以从字符串s的末尾删除1和或者多个字符,保证删除之后的字符串还是一个偶串,牛牛想知道删除之后得到最长偶串长度是多少。输入:abaababaab输出:6#i...

2017-07-26 15:01:00 174

转载 微信接口基本类 与连接

<?php/** * 微信公众平台操作类 */class WeChat { private $_appid; private $_appsecret; private $_token;// 公众平台请求开发者时需要标记 //表示QRCode的类型 const QRCODE_TYPE_TEMP = 1; const QRCODE...

2017-07-20 16:09:00 150

转载 给出两个字符串(可能包含空格),找出其中最长的公共连续子串,输出其长度。...

#include <stdio.h> #include <string.h> #define N 50 int main(){ char s1[N],s2[N]; int dp[N][N],i,j,max_len=0; gets(s1); gets(s2); for(i=0...

2017-07-12 09:14:00 1225

转载 php 图表的操作

<?php $dir=dirname(__FILE__);//查找当前脚本所在路径 require $dir."/db.php";//引入mysql操作类文件 require $dir."/PHPExcel/PHPExcel.php";//引入PHPExcel $db=new db($phpexcel);//实例化db类 连接数据库 $objPHPExce...

2017-07-11 19:39:00 99

转载 php 操作excel

<?php $dir=dirname(__FILE__);//查找当前脚本所在路径 require $dir."/db.php";//引入mysql操作类文件 require $dir."/PHPExcel/PHPExcel.php";//引入PHPExcel $db=new db($phpexcel);//实例化db类 连接数据库 $objPHPExce...

2017-07-11 19:13:00 79

转载 数据库导入Exel,输入到浏览器

db.php<?php require dirname(__FILE__)."/dbconfig.php";//引入配置文件 class db{ public $conn=null; public function __construct($config){//构造方法 实例化类时自动调用 $this->conn=mysql_...

2017-07-11 18:45:00 74

转载 php生成Exeple表demo

<?phprequire "./PHPExcel.php";$dir=dirname(__FILE__);$objPHPExcel=new PHPExcel();$objSheet=$objPHPExcel->getActiveSheet();//获得当前活动的sheet$objSheet->setTitle("demo");$array=a...

2017-07-11 17:29:00 70

转载 请编写一个方法,返回某集合的所有非空子集。 给定一个int数组A和数组的大小int n,请返回A的所有非空子集。保证A的元素个数小于等于20,且元素互异。各子集内部从大到小排序,子集之间字典逆序排序,...

题解:观察测试样例,会发现每个子集的选择规律与二进制((2^n) - 1)到 1 的顺序生成的规律是一致的,样例中n=3,2^n-1=7,用二进制表示为111,其中每一位的1表示数组中的三个数都选择。class Subset {public: vector<vector<int> > getSubsets(vector<int> ...

2017-07-11 08:19:00 553

转载 面试

牛牛有一个鱼缸。鱼缸里面已经有n条鱼,每条鱼的大小为fishSize[i] (1 ≤ i ≤ n,均为正整数),牛牛现在想把新捕捉的鱼放入鱼缸。鱼缸内存在着大鱼吃小鱼的定律。经过观察,牛牛发现一条鱼A的大小为另外一条鱼B大小的2倍到10倍(包括2倍大小和10倍大小),鱼A会吃掉鱼B。考虑到这个,牛牛要放入的鱼就需要保证:1、放进去的鱼是安全的,不会被其他鱼吃掉2、这条鱼放进去...

2017-07-07 14:57:00 47

转载 Observer(观察者模式)

某个对象可以被设置为是可观察的,只要通过某种方式允许其他对象注册为观察者。每当被观察的对象改变时,会发送信息给观察者。<?php interface Observer { function onChanged($sender, $args);} interface Observable { function addObserver($obse...

2017-07-04 13:39:00 76

转载 Strategy(策略模式)

测试模式主要为了让客户类能够更好地使用某些算法而不需要知道其具体的实现。<?php interface OutputInterface { public function load();} class SerializedArrayOutput implements OutputInterface { public function ...

2017-07-04 13:37:00 87

转载 Adapter(适配器模式)

这种模式允许使用不同的接口重构某个类,可以允许使用不同的调用方式进行调用:<?php class SimpleBook { private $author; private $title; function __construct($author_in, $title_in) { $this->aut...

2017-07-04 13:35:00 65

转载 Decorator(装饰器模式)

装饰器模式允许我们根据运行时不同的情景动态地为某个对象调用前后添加不同的行为动作。<?phpclass HtmlTemplate { // any parent class methods} class Template1 extends HtmlTemplate { protected $_html; pub...

2017-07-04 12:48:00 53

转载 Builder(构造者)

Builder(构造者)<?php class Product { private $name; public function setName($name) { $this->name = $name; } public function getName() { r...

2017-07-04 12:33:00 72

转载 Prototype(原型模式)

有些时候,部分对象需要被初始化多次。而特别是在如果初始化需要耗费大量时间与资源的时候进行预初始化并且存储下这些对象。<?php interface Product {} class Factory { private $product; public function __construct(Product $produc...

2017-07-04 12:20:00 80

转载 AbstractFactory(抽象工厂模式)

AbstractFactory(抽象工厂模式)  有些情况下我们需要根据不同的选择逻辑提供不同的构造工厂,而对于多个工厂而言需要一个统一的抽象<?php class Config { public static $factory = 1;} interface Product { public function getName()...

2017-07-04 11:27:00 59

转载 工厂模式

工厂模式是另一种非常常用的模式,正如其名字所示:确实是对象实例的生产工厂。某些意义上,工厂模式提供了通用的方法有助于我们去获取对象,而不需要关心其具体的内在的实现<?php interface Factory { public function getProduct();} interface Product { public fun...

2017-07-04 11:25:00 57

转载 Singleton(单例模式)

Singleton(单例模式)  单例模式是最常见的模式之一,在Web应用的开发中,常常用于允许在运行时为某个特定的类创建一个可访问的实例。<?php/** * Singleton class */final class Product{ /** * @var self */ private stat...

2017-07-04 11:17:00 73

转载 对于一棵二叉树,请设计一个算法,创建含有某一深度上所有结点的链表。 给定二叉树的根结点指针TreeNode* root,以及链表上结点的深度,请返回一个链表ListNode,代表该深度上所有结点的值,...

/*struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) { }};*//*struct Lis...

2017-07-03 11:00:00 150

转载 Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right,...

class Solution { public: vector<vector<int>> levelOrder(TreeNode* root) { vector<vector<int>> res; if (root == NULL) {...

2017-07-03 10:17:00 161

转载 Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k...

class Solution { public: ListNode *reverseKGroup(ListNode *head, int k) { if (!head || !(head->next) || k < 2) return head; // c...

2017-07-01 19:25:00 138

转载 c++ list, vector, map, set 区别与用法比较

List封装了链表,Vector封装了数组, list和vector得最主要的区别在于vector使用连续内存存储的,他支持[]运算符,而list是以链表形式实现的,不支持[]。Vector对于随机访问的速度很快,但是对于插入尤其是在头部插入元素速度很慢,在尾部插入速度很快。List对于随机访问速度慢得多,因为可能要遍历整个链表才能做到,但是对于插入就快的多了,不需要拷贝和移动数据,...

2017-06-28 15:49:00 53

转载 Leetcode. 回文字符串的分割和最少分割数

Q1: 回文字符串的分割Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return...

2017-06-28 07:55:00 386

转载 指定字符串 s,返回 s 所有可能的子串,每个子串必须是一个回文(指顺读和倒读都一样的字符串)...

Given a string s, partition s such that every substring of the partition is a palindromeReturn all possible palindrome partitioning of s.For example, given s = "aab",Return [ ["a...

2017-06-25 22:15:00 223

转载 Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull. ...

Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:思路: 1)同linked-list-cycle-i一题,使用快慢指针方法,判定是否存在环,并记录两指针相遇位置(Z); 2)将两指针分别放在链表头(X)和相...

2017-06-25 15:44:00 117

转载 Sort a linked list in O(n log n) time using constant space complexity.

因为题目要求复杂度为O(nlogn),故可以考虑归并排序的思想。归并排序的一般步骤为:1)将待排序数组(链表)取中点并一分为二;2)递归地对左半部分进行归并排序;3)递归地对右半部分进行归并排序;4)将两个半部分进行合并(merge),得到结果。所以对应此题目,可以划分为三个小问题:1)找到链表中点 (快慢指针思路,快指针一次走两步,慢指针一次走一步,快...

2017-06-19 10:11:00 36

转载 map 插入数据的方式局别

#include<map>#include<iostream>usingnamespace std;int main(){map <int, int> m1, m2, m3;map <int,int>::iterator m1_Iter;m1.insert( pair <int, int&g...

2017-06-17 16:33:00 72

转载 添加字符--全国模拟(三)

[编程题] 添加字符时间限制:1秒空间限制:32768K牛牛手里有一个字符串A,羊羊的手里有一个字符串B,B的长度大于等于A,所以牛牛想把A串变得和B串一样长,这样羊羊就愿意和牛牛一起玩了。而且A的长度增加到和B串一样长的时候,对应的每一位相等的越多,羊羊就越喜欢。比如"abc"和"abd"对应相等的位数为2,为前两位。牛牛可以在A的开头或者结尾添加任意字符,...

2017-06-15 22:43:00 105

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除