自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

早睡早起好少年

为什么坚持 想一想当初

  • 博客(160)
  • 资源 (5)
  • 收藏
  • 关注

原创 StringBuffer为什么是线程安全的,StringBuilder为什么不是是线程安全的,以及它们的使用场景(代码测试验证)

我们都知道StringBuffer是线程安全,而StringBuilder不是线程安全的(原因大家肯定也知道,StringBuffer中的方法都加了synchronized关键字)。所以网上很多资料都说,多线程不要用StringBuilder,否则会出现问题。但是它们的使用场景,我之前不是很明白,也和对多线程了解不深有一定原因。先看一段代码:package bingfa;/** * Stri...

2018-06-26 16:59:15 23867 7

原创 泛型Class<T>和 T

private T product;private Class product; 这两个有什么区别呢,查了资料才知道,单独的T 代表一个类型 而 Class代表这个类型所对应的类public T find(Class clazz, int id);根据类来反射生成一个实例,而单独用T没法做到。例T jsonStri

2016-07-03 20:38:03 409

原创 struts手动转发数据

HttpServletRequest  request = ServletActionContext.getRequest();ServletActionContext.getActionContext(request).getSession().put("username",username+"哈哈");或ActionContext.getContext().put(

2016-07-01 21:09:39 324

原创 Servlet基本接口与类

1.HttpServletRequest接口  在软件包javax.servlet.http中,jsp内置对象request是该接口的一个实例。2.HttpServletResponse接口  在软件包javax.servlet.http中,jsp内置对象response是该接口的实例。3.HttpSession接口  在软件包javax.servlet.htt

2016-06-30 20:17:50 406

原创 JaveWeb--Servlet中实现转发

Servlet中实现转发在servlet中,一般是获取RequestDispatcher,然后调用forward方法进行转发。方法一用request获取。RequestDispatcher r = request.getRequestDispatcher("目标页面");方法二用ServletContext获取。1. 直接获取ServletCon

2016-06-27 22:05:02 472

原创 JAVA的MD5和SHA-256和SHA-512 的 Hash 算法的调用

class Encrypt{ /** * 传入文本内容,返回 SHA-256 串 * * @param strText * @return */ public String SHA256(final String strText) { return SHA(strText, "SHA-256"); } /** * 传入文本内容

2016-06-13 20:18:54 4573

原创 java抽象类-接口

接口可以继承(extends)接口,而且支持多重继承。但是抽象类不能继承接口,可以通过implements去实现接口,且可以不用实现接口的方法

2016-06-05 16:32:26 230

原创

EL表达式

2016-04-12 19:53:16 223

原创 leetcode-338-Counting Bits

338. Counting BitsGiven a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.

2016-03-19 11:09:40 1455

原创 利用JPcap进行抓包

JPCAP实际上并非一个真正去实现对数据链路层的控制,而是一个中间件,JPCAP调用wincap/libpcap,而给JAVA语言提供一个公共的接口,从而实现了平台无关性。在官方网站上声明,JPCAP支持FreeBSD 3.x, Linux RedHat 6.1, Fedora Core 4, Solaris, and Microsoft Windows 2000/XP等系统。参考

2016-03-14 22:05:04 7971 4

原创 leetcode-189.-Rotate Array

Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Note:Try to come up as many solutions as

2016-03-09 20:58:19 271

原创 leetcode-328-Odd Even Linked List

Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.You should try to do it in

2016-03-07 22:46:05 291

原创 计算机网络

1>.当一个IP数据报封装成链路层的帧时,此数据报的总长度(即报头区加上数据部分)一定不能超过下层的数据链路层的MTU值,否则无法传输。 因          此,我们需要对IP包进行分片,其中IP数据报的首部中,和IP数据包分片有关的字段为——总长度、标识、标志以及位偏移.分片由网络层的路由器完        成。     目的主机收到所有分片后,对分片进行重新组装还原的过程叫做IP

2016-03-06 14:50:51 290

原创 leetcode-257-Binary Tree Paths

Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1->2->5", "1->3"]输出所有 从根

2016-03-03 11:29:29 279

原创 leetcode-88-Merge Sorted Array

Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater or equal to m +

2016-03-02 18:11:32 274

原创 leetcode-26-Remove Duplicates from Sorted Array

Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with

2016-03-02 16:49:54 262

原创 leetcode-326-Power of Three

Given an integer, write a function to determine if it is a power of three.Follow up:Could you do it without using any loop / recursion?Credits:Special thanks to @dietpepsi for adding this

2016-01-11 23:22:00 555

原创 函数指针数组

函数指针数组#include //函数指针数组int func1(int n){ printf("func1: %d\n", n); return n;}int func2(int n){ printf("func2: %d\n", n); return n;}int main(){ //函数 //返回值

2015-12-30 22:06:47 394

原创 Django学习之manage.py使用

1.django-admin.py startproject mysite 开始一个项目,会初始化一些项目的结构文件2.python manage.py runserver ip:port 如: python manage.py runserver 127.0.0.1:8080 利用ip可以访问不在同一个主机的数据库3.python manage.py syncdb 注:会创建在se

2015-10-27 22:49:32 448

原创 Django学习笔记(一)

配置django运行环境,创建一个简单的项目。首先,安装Python。ubuntu下已经自带Python,故无需安装。Windows下安装也比较简单,不赘述。安装pip。pip是一个安装和管理Python包的工具,非常方便。sudo apt-get install python-pip安装django。有了pip,就容易安装任意Pyt

2015-10-19 13:26:23 422

原创 leetcode-292-Nim Game

Nim GameYou are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last

2015-10-18 20:20:42 375

原创 巴什博奕

下面这段来自白白の屋的文章的一段:巴什博弈:只有一堆n个物品,两个人轮流从这堆物品中取物,规定每次至少取一个,最多取m个。最后取光者得胜。    显然,如果n=m+1,那么由于一次最多只能取m个,所以,无论先取者拿走多少个,后取者都能够一次拿走剩余的物品,后者取胜。因此我们发现了如何取胜的法则:如果n=(m+1)r+s,(r为任意自然数,s≤m),那么先取者要拿走s个物品,如果

2015-10-18 20:14:11 364

原创 02-线性结构1 一元多项式的乘法与加法运算

02-线性结构1 一元多项式的乘法与加法运算   (20分)设计函数分别求两个一元多项式的乘积与和。输入格式:输入分2行,每行分别先给出多项式非零项的个数,再以指数递降方式输入一个多项式非零项系数和指数(绝对值均为不超过1000的整数)。数字间以空格分隔。输出格式:输出分2行,分别以指数递降方式输出乘积多项式以及和多项式非零项的系数和指数。数字间以空格分隔,

2015-10-04 22:25:45 562

原创 堆,优先队列

用最大堆实现排序#include // Myself 15-9-26#includeusing namespace std;void Adjust_Heap(int* a,int i,int n) { // 调整最大堆 if (i > n/2) return ; // 叶子节点 无需调整 int le = i<<1; int ri = i<<1|1; i

2015-09-26 19:54:26 282

原创 kinds of sort

各种排序算法#include#include#includeusing namespace std;void change(int *a,int *b) /// change{ int t=*a; *a=*b; *b=t;}void print(int *a,int n) /// print{ for(int i=0;i<n;i++)

2015-09-23 22:41:35 374

原创 leetcode-107-Binary Tree Level Order Traversal II

Binary Tree Level Order Traversal IIGiven a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For e

2015-09-23 18:36:06 369

原创 leetcode-102-Binary Tree Level Order Traversal

Binary Tree Level Order TraversalGiven a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree {3,9,20,#,

2015-09-22 20:16:08 314

原创 leetcode-101-Symmetric Tree

Symmetric TreeFor example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the following is not: 1 / \ 2 2 \ \ 3 3Note:B

2015-09-21 21:13:19 305

原创 leetcode-283-Move Zeroes

Move ZeroesGiven an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 1

2015-09-21 13:20:51 324

原创 leetcode-110-Balanced Binary Tree

Balanced Binary TreeGiven a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subt

2015-09-21 12:57:37 319

原创 leetcode-172-Factorial Trailing Zeroes

Factorial Trailing ZeroesGiven an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.求 n!中,末尾的0连续有多少个。例如 10!=10*

2015-08-31 19:25:09 487

原创 leetcode-258-Add Digits

Add DigitsGiven a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2.

2015-08-31 13:19:39 571

原创 leetcode-263-Ugly Number

Ugly Number  Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly

2015-08-24 09:47:40 582

原创 leetcode-118-Pascal's Triangle

Pascal's TriangleGiven numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1

2015-08-23 19:05:55 534

原创 leetcode-155-Min Stack

Min Stack Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of t

2015-08-04 18:14:58 556

原创 leetcode-67-Add Binary

Add BinaryGiven two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".两字符串表示的2进制数。求它们的和。直接模拟,从最后一位开始每一位都相加,结果保存在栈中。class Solut

2015-08-03 18:41:59 509

原创 leetcode-225-Implement Stack using Queues

Implement Stack using Queues  Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() --

2015-08-03 17:44:43 533

原创 leetcode-232-Implement Queue using Stacks

Implement Queue using Stacks  Implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue.pop() -- Removes the element from in front of queue.pe

2015-08-03 17:29:45 360

原创 leetcode-190-Reverse Bits

Reverse Bits  Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represen

2015-08-01 22:34:58 487

原创 leetcode-242-Valid Anagram

Valid Anagram  Given two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return f

2015-08-01 21:27:47 711

[溜客资源论坛提供]C++黑客编程揭秘与防范

黑客资料,了解Hacker,覆盖知识广,有兴趣可以看一下

2014-11-13

微软面试100题

经典的微软面试100题,详细讲解,对算法的学习大有帮组,对即将面试的同学更是不用说。

2014-08-27

c/c++语言参考

包含c++各种库函数,以及c的函数,c++中STL里的各种函数用法,很经典,即可作为入门基础,又可以当做工具书。

2014-08-27

UNIX环境高级编程(第二版)

UNIX操作系统,讲的很详细,适合新手, 绝对不坑

2014-08-20

《算法导论》

《算法导论》是一部很经典的书,里面包含了许多算法知识,深入浅出,图论,搜索,数据结构,应有尽有。对搞ACM的帮组极大。

2014-08-15

空空如也

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

TA关注的人

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