Skip to content

Instantly share code, notes, and snippets.

@wintercn
wintercn / RemoveMultipleSpaces.cs
Created Mar 28, 2012 — forked from Ninputer/RemoveMultipleSpaces.cs
模拟微面试之去空格
View RemoveMultipleSpaces.cs
//请实现下面的函数,输入参数baseStr是一个(可以更改的)字符串,请将其中所有连续出现的多个空格都替换成一个空格,单一空格需保留。
//请直接使用baseStr的空间,如需开辟新的存储空间,不能超过o(N)(注意是小o,N是字符串的长度)。返回值是替换后的字符串的长度。
//样例代码为C#,但可以使用任何语言。如需使用任何库函数,必须同时给出库函数的实现。
class Program
{
public static int RemoveMultipleSpaces(char[] baseStr)
{
int r = 0, w = 0;
char c;
while (r < baseStr.Length)
@wintercn
wintercn / h5g
Last active May 19, 2017
HTML5 Canvas Game Template
View h5g
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<!--允许全屏-->
<meta content="yes" name="apple-mobile-web-app-capable"/>
<meta content="yes" name="apple-touch-fullscreen"/>
<!--禁止电话号码和邮箱识别-->
@wintercn
wintercn / gist:3923697
Created Oct 20, 2012
计算“某个范围内能被最多的数整除的数”
View gist:3923697
var primes = [2,3,5,7,11,13,17];
function find(n){
var table = new Array(n+1);
table[1] = [0,0,0,0,0,0,0];
for(var i = 1;i<n;i++) {
if(!table[i]) {
table[i] = [0,0,0,0,0,0,0];
continue;
}
@wintercn
wintercn / gist:5342839
Created Apr 9, 2013
取两个HTML节点最近的公共父节点
View gist:5342839
function getCommonParent(el1,el2){
var parents1 = [];
var el = el1;
while(el) {
parents1.unshift(el);
el = el.parentNode;
}
var parents2 = [];
@wintercn
wintercn / coins.js
Last active Mar 23, 2019
现在有1分、2分、5分的硬币各无限枚,要凑成1元有多少种凑法?
View coins.js
function getResult(n,coins) {
var a = new Array(n+1);
for(var i = 0; i <= n;i++)
a[i] = 0;
a[0] = 1;
for(var j = 0; j<coins.length; j++)
@wintercn
wintercn / svg.vba
Created May 17, 2013
把Powerpoint矢量图生成SVG的VBA
View svg.vba
' svg.vba released 11.08.2002
Private Function get_export_scaling_factor() As Single
'' point to pixel conversion factor
get_export_scaling_factor = (4 / 3)
End Function
@wintercn
wintercn / showboxes.js
Created May 21, 2013
显示页面的盒结构
View showboxes.js
function randomColor(){
return "rgb("+Math.floor(Math.random()*255)+","+Math.floor(Math.random()*255)+","+Math.floor(Math.random()*255)+")";
}
function showBoxes(window) {
var rects = [];
function getRects(node){
var range = window.document.createRange();
range.setStartBefore(node);
range.setEndAfter(node);
@wintercn
wintercn / HTMLLexicalParser.js
Last active Aug 5, 2019
HTML语法分析器模型
View HTMLLexicalParser.js
function StartTagToken(){
}
function EndTagToken(){
}
function Attribute(){
}
@wintercn
wintercn / gist:5918272
Created Jul 3, 2013
CSS3 标准和属性对应数据
View gist:5918272
[
{
"spec name": "CSS Animations",
"uri": "http://www.w3.org/TR/css3-animations",
"category": "css-property",
"Name": "animation-name",
"Value": "<single-animation-name> [\n ‘,’ <single-animation-name> ]*",
"Initial": "‘none’",
"Applies To": "all elements, ::before and ::after pseudo-elements",
"Inherited": "no",
View standards
[
{
name:"HTML5",
uri:"http://www.w3.org/TR/html5/single-page.html",
category:"markup"
},
{
name:"HTML 5.1",
uri:"http://www.w3.org/TR/html51/single-page.html",
category:"markup"