Skip to content

Instantly share code, notes, and snippets.

View pezy's full-sized avatar
💭
I may be slow to respond.

peizhe.chen pezy

💭
I may be slow to respond.
  • Beijing, China
View GitHub Profile
@pezy
pezy / ex12_1_2_3_4_5.cpp
Last active April 9, 2018 18:03
乱炖exercise 12.3
/***************************************************************************
* @file The code is for the exercises in C++ Primmer 5th Edition
* @author Alan.Wang
* @date 22 DEC 2013
* @remark
***************************************************************************/
//!
//! Exercise 12.1:
//! How many elements do b1 and b2 have at the end of this code?
// b1 : 4
@pezy
pezy / standards
Last active August 29, 2015 14:06 — forked from wintercn/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"
@pezy
pezy / MultidimensionalArray.cpp
Last active August 29, 2015 14:06
茴字的四种写法(C++)
#include <iostream>
using std::cout; using std::endl; using std::begin; using std::end;
int main()
{
constexpr size_t rowCnt = 3, colCnt = 4;
int ia[rowCnt][colCnt];
// subscirpting
//
// main.cpp
// Test
//
// Created by pezy on 9/11/14.
// Copyright (c) 2014 PEZY. All rights reserved.
//
#include<iostream>
using namespace std;
@pezy
pezy / Color.cpp
Created November 15, 2014 08:18
OSG && Qt functional
const osg::Vec4 toVec4(const QColor &color)
{
return osg::Vec4(
color.redF()
, color.greenF()
, color.blueF()
, color.alphaF());
}
const QColor toQColor(const osg::Vec4 &color)
#include <map>
#include <string>
#include <fstream>
std::string num2Chinese(int num, std::map<int, std::string> &map) {
std::string ret;
bool twenty{num > 20};
bool remnant{num > 100 && num/10%10 == 0};
for (auto it=map.crbegin(); it != map.crend(); ++it) {
int count=0;
#include <windows.h>
#include <stdio.h>
void main()
{
HANDLE hFile;
HANDLE hAppend;
DWORD dwBytesRead, dwBytesWritten, dwPos;
BYTE buff[4096];
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/textmate");e.getSession().setMode("ace/mode/c_cpp");</script>
@pezy
pezy / Solution.h
Last active August 29, 2015 14:17
20 行的快排(以尾巴为轴,与 CLRS 保持一致)
#include <algorithm>
class Solution {
int partition(int arr[], int l, int r) {
int index = l, pivot = arr[r];
for (int i=l; i<r; ++i)
if (arr[i] <= pivot) std::swap(arr[i], arr[index++]);
std::swap(arr[index], arr[r]);
return index;
}
#include <iostream>
#include <initializer_list>
struct ListNode {
int val;
ListNode *next;
ListNode(int x) : val(x), next(nullptr) {}
};
ListNode *create_linkedlist(std::initializer_list<int> lst)