- 博客(322)
- 收藏
- 关注
原创 Euler: Integer right triangles
If p is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are exactly three solutions for p = 120. {20,48,52}, {24,45,51}, {30,40,50}p是三边长度均为整数的直角三角形的周长,当p=120时,存在三种直角三
2015-05-13 20:27:41
1245
原创 学习JavaScript的闭包
从外部访问函数局部变量变量有局部变量和全局变量。对于函数的局部变量,在函数内部可以访问,在函数外部无法访问。对于全局变量,在函数内部和外部都可以访问。闭包是什么?Javascript允许在函数中定义内部函数,将内部函数返回,这时候会产生闭包。 闭包中含有一种特殊的局部变量,在函数结束返回后仍然存在。 闭包中的局部变量是引用而不是拷贝。返回内部函数function makeFunc() { v
2015-05-12 21:36:15
1047
原创 Leetcode: Department Highest Salary
The Employee table holds all employees. Every employee has an Id, a salary, and there is also a column for the department Id.+—-+——-+——–+————–+ | Id | Name | Salary | DepartmentId | +—-+——-+——–+————
2015-03-19 18:10:41
1164
原创 Euler: Non-abundant sums
ProblemA perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which me
2015-03-18 23:05:45
880
原创 Leetcode: Rank Scores
Write a SQL query to rank scores. If there is a tie between two scores, both should have the same ranking. Note that after a tie, the next ranking number should be the next consecutive integer value. I
2015-03-18 21:59:05
1066
原创 Leetcode: Consecutive Numbers
Write a SQL query to find all numbers that appear at least three times consecutively. +—-+—–+ | Id | Num | +—-+—–+ | 1 | 1 | | 2 | 1 | | 3 | 1 | | 4 | 2 | | 5 | 1 | | 6 | 2 |
2015-03-16 22:20:32
831
原创 Leetcode : Customers Who Never Order
Now we’ve got two table. One customer table for customerid and their names, One Order tablefor customers’ Id that bought something. We will find the customers that in the customer table but not in ord
2015-03-15 22:43:40
816
原创 Leetcode: find all duplicate
Leetcode : Duplicate EmailsWrite a SQL query to find all duplicate emails in a table named Person. +—-+———+ | Id | Email | +—-+———+ | 1 | a@b.com | | 2 | c@d.com | | 3 | a@b.com | +—-+———+
2015-03-15 22:27:45
907
原创 Leetcode: 相关子查询
Leetcode : Employees Earning More Than Their Managers+—-+——-+——–+———–+ | Id | Name | Salary | ManagerId | +—-+——-+——–+———–+ | 1 | Joe | 70000 | 3 | | 2 | Henry | 80000 | 4 |
2015-03-14 19:01:44
783
原创 Leetcode: Second Highest Salary
Write a SQL query to get the second highest salary from the Employee table.+—-+——–+ | Id | Salary | +—-+——–+ | 1 | 100 | | 2 | 200 | | 3 | 300 | +—-+——–+ For example, given the abov
2015-03-14 00:00:58
807
原创 Euler: Digit fifth powers
Problem 30: Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits:1634 = 1^4 + 6^4 + 3^4 + 4^4 8208 = 8^4 + 2^4 + 0^4 + 8^4 9474 = 9^4 + 4^4 + 7^4
2015-03-12 19:54:15
759
原创 Euler: Counting Sundays
Problem 19. You are given the following information, but you may prefer to do some research for yourself.1 Jan 1900 was a Monday.Thirty days has September, April, June and November. All the rest hav
2015-03-11 21:07:22
681
原创 Euler: Names scores
Problem 22: Using names.txt, a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this
2015-03-10 22:51:31
746
原创 Euler: Amicable numbers
Amicable numbersThis is the 21st issue of Euler Project Challenge Game.Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n).
2015-03-09 19:03:21
1477
原创 Leetcode:Excel Sheet Column Number
Leetcode增加了Accepted Solutions Runtime Distribution,能够看到自己的代码的效率和别人比起来在怎么样的位子。优快云博客终于推出了Markdown格式写博客。
2015-03-09 17:27:30
1542
原创 数组的最大子数组积 Maximum Product Subarray
题目:Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4],the contiguous subarray [2,3] has the large
2014-10-20 10:40:24
1266
原创 寻找循环有序数组的最小值 Find Minimum in Rotated Sorted Array
二分查找是典型的分治思想,主要应用于有序顺组相关的查找问题。典型
2014-10-20 10:14:02
2571
原创 printf趣味程序
下面这个单行程序里包含了不少知识:main() { printf(&unix["\021%six\012\0"],(unix)["have"]+"fun"-0x60);}1:unix默认值main(){ printf(“%d”, unix); }2:数组表示法数组的表示法:str[n] 等价于 (n)[str] ,等价于 str + n,就
2014-08-29 13:48:17
1011
原创 A-star路径搜索
启发式搜索在于当前搜索结点往下选择下一步结点时,可以通过一个启发函数来进行选择,选择代价最少的结点作为下一步搜索结点而跳转其上。 DFS和BFS在展开子结点时均属于盲目型搜索,它不会选择哪个结点在下一次搜索中更优而去跳转到该结点进行下一步的搜索。与DFS,BFS不同的是,选择的启发函数,可以很快得到一个搜索问题的最优解A*搜寻算法 A*搜寻算法,俗称A星算法,作为启
2014-06-03 10:42:24
1903
原创 TCP连接的关闭过程
客户端一般是主动关闭方,直接在程序在调用close()函数发出关闭请求(会发送fin报文)。服务器端一般是关闭被动方,不会主动调用close()函数。
2014-05-23 18:55:19
4969
原创 解析XML文件
XML(Extensible Markup Language)是一种标记语言,被设计用来传输和存储数据,而不是用于显示数据。它和JSON(JavaScript Object Notation)的作用是一致的。既然XML的作用在于传送数据,那么两件重要的事情就是XML的生成和解析这两个逆向的过程。XML的文件格式由W3C指定统一的标准,不管什么编程语言,只要按照其标准进行,就可以正确的生
2014-05-15 20:09:43
991
原创 判断平面上一点是否在三角形内 Inside a triangle or not
平面内有一个三角形,三个顶点的坐标已经给出。现在给出一个坐标点,
2014-05-14 21:14:39
2114
翻译 Python编程中容易出现的10个错误
Python是一个解释型、面向对象、具有动态语义的高级语言。它具有高级数据结构、动态类型绑定,支持模块化。由于Python程序员往往并非只会这一门语言,受其他语言的影响,我们在编写Python代码的时候容易出现一些错误,本文中列出了10点。一、函数参数默认值Python允许定义函数参数的默认值,这和C/C++是一致的。但是所不同的是,解释器只对该默认参数赋值一次。
2014-05-10 22:28:24
1911
原创 实现线程读写锁的四种方法
对于某个临界互斥资源,读写锁:当已经被加了读锁时,其他的读模式锁请求仍然可以访问,但是写模式锁不能访问;当写模式锁加锁时,其他的请求都不能访问。
2014-05-07 21:19:15
13737
2
原创 标准模板库的空间配置器 STL's allocator
标准模板库中利用空间配置器来在幕后管理内存空间,有下面两种空间配置器。一种是标准的空间配置器std:allocator一种是高级的空间配置器std:alloc
2014-05-04 22:38:26
1080
原创 阿拉伯数字转换为汉语表达方式
汉语博大精深,讲一个简单的阿拉伯数字转换为我们比如 1980,要转换为“一千九百八十”;198 要转换为“一百九十八”;19 要转换为“十九”,1要转换为“一”。数值:零一二三四五六七八九小权值:十 百 千 大权值:万 亿特殊用例:1、注意0的出现。1080、1008、1800、10000、1000000、100000000。2、如果某个大权值内的四位都是0
2014-05-01 18:43:35
2855
原创 C++的虚函数 Virtual Function
virtual有两个用处。 一个是最常见的: virtual关键字修饰类的成员函数。另一个是虚基类机制,用于多重继承。在定义派生类时,要在基类描述前加关键字virtual。避免内存中父虚基类成员的重复放置。虚函数:定义:虚函数必须是类的 非静态成员函数 且 非构造函数,其访问权限是public(可以定义为private or proteceted,但是对于多
2014-04-29 16:26:56
1160
原创 TCP的网络连接建立过程
套接字描述符套接字描述符是int类型的。套接字描述符是文件描述符的一种,是UNIX系统中内核对各种类型文件的标识。网络地址结构体sockaddr_in结构体struct sockaddr_in { short sin_family; /* Address family 一般来说 AF_INET(地址族)PF_INET(协议族 )*/
2014-04-24 09:43:21
1862
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人