自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(125)
  • 收藏
  • 关注

原创 STL之deque

deque概述deque是一种双向的连续性空间。所谓双向开口,意思是可以在头尾两端分别做元素的插入操作。 deque采用一块所谓的map作为主控。这里的所谓map是一块连续空间,其中每个元素都是指针,指向另一段(较大)连续空间,称为缓冲区,缓冲区才是deque的储存空间主体。template<class T,class Alloc=alloc,size_t Buffsiz=0>class d

2017-07-31 12:30:44 280

原创 STL之list

STL的List节点STL的List节点结构如下struct node{ T data; node *prev; node *next; list<T> *container; };显然是List是一个双向链表。STL的List迭代器list不再像vector一样能以普通指针当做迭代器,因为其节点

2017-07-29 10:08:47 284

转载 C++中虚函数工作原理和(虚)继承类的内存占用大小计算

原文地址:http://blog.csdn.net/hackbuteer1/article/details/7883531一、虚函数的工作原理      虚函数的实现要求对象携带额外的信息,这些信息用于在运行时确定该对象应该调用哪一个虚函数。典型情况下,这一信息具有一种被称为 vptr(virtual table pointer,虚函数表指针)的指针的形式。vptr 指向一个被称为 v

2017-07-28 18:05:24 229

转载 c++对象多继承的内存结构

首先介绍一下C++中有继承关系的类对象内存的布局: 在C++中,如果类中有虚函数,那么它就会有一个虚函数表的指针__vfptr,在类对象最开始的内存数据中。之后是类中的成员变量的内存数据。 对于子类,最开始的内存数据记录着父类对象的拷贝(包括父类虚函数表指针和成员变量)。 之后是子类自己的成员变量数据。 对于子类的子类,也是同样的原理。但是无论继承了多少个子类,对象中始终只有一个虚函数

2017-07-28 18:00:48 477

原创 STL之vector

STL之vectorvector的数据以及操作方式,与array非常相似。但是array是静态空间,一旦配置了就不能改变;而vector是动态空间,随着元素的加入,它的内部机制会自行扩充空间以容纳新元素,因此vector的运用对于内存的合理使用与运用的灵活性有很大的帮助。vector的迭代器vector维护的是一个连续线性空间,所以不论其元素为何,普通指针都可以作为vector的迭代器而满足所有的要

2017-07-22 15:24:40 226

原创 STL迭代器

STL迭代器迭代器是一种行为类似指针的对象,而指针的各种行为中最重要的便是内容提领和成员访问,因此,迭代器最重要的编程工作就是对operator* 和operator->进行,下面以find函数为例: template <class InputIterator,typename T> InputIterator find(InputIterator fitst,InputIterato

2017-07-17 14:11:59 163

原创 STL空间配置器

STL空间配置器空间配置器在STL中,STL的空间配置器是一个名为allocator的模板类,allocator有几个重要个接口,分别为allocator::allocate(),allocator::deallocate(),allocator::construct(),allocator::destroy()。上述所说的allocator只是基层内存配置/释放行为(也就是::operator

2017-07-16 16:09:43 256

原创 k-近邻算法

最近读了《机器学习实战》,本文是一些读后笔记.  K-邻近算法描述:简单来说,k-邻近算法才用测量不同特征值之间的距离方法进行分类。优点:进度高,对异常值不敏感,无数据输入假定。缺点:计算复杂度高,空间复杂度高适用数据范围:数值型和标称型。工作原理:存在一个样本数据集合,也称作训练样本集,并且样本集中每个数据都存在标签,即我们知道样本集中每一数据与所属分类的对应关系,输入没

2017-03-16 15:20:33 172

原创 #1075 : 开锁魔法III

描述一日,崔克茜来到小马镇表演魔法。其中有一个节目是开锁咒:舞台上有 n 个盒子,每个盒子中有一把钥匙,对于每个盒子而言有且仅有一把钥匙能打开它。初始时,崔克茜将会随机地选择 k 个盒子用魔法将它们打开。崔克茜想知道最后所有盒子都被打开的概率,你能帮助她回答这个问题吗?输入第一行一个整数 T (T ≤ 100)表示数据组数。 对于每组数据,第一行有两个整数 n 和 k (1 ≤

2017-03-11 19:12:50 227

原创 #1055 : 刷油漆

描述上回说到,小Ho有着一棵灰常好玩的树玩具!这棵树玩具是由N个小球和N-1根木棍拼凑而成,这N个小球都被小Ho标上了不同的数字,并且这些数字都是处于1..N的范围之内,每根木棍都连接着两个不同的小球,并且保证任意两个小球间都不存在两条不同的路径可以互相到达。没错,这次说的还是这棵树玩具的故事!小Ho的树玩具的质量似乎不是很好,短短玩了几个星期,便掉漆了!“简直是一场噩梦!”小Ho拿着

2017-03-11 19:12:03 210

原创 #1014 : Trie树

描述小Hi和小Ho是一对好朋友,出生在信息化社会的他们对编程产生了莫大的兴趣,他们约定好互相帮助,在编程的学习道路上一同前进。这一天,他们遇到了一本词典,于是小Hi就向小Ho提出了那个经典的问题:“小Ho,你能不能对于每一个我给出的字符串,都在这个词典里面找到以这个字符串开头的所有单词呢?”身经百战的小Ho答道:“怎么会不能呢!你每给我一个字符串,我就依次遍历词典里的所有单词,检查你给

2017-03-11 19:10:26 120

原创 #1015 : KMP算法

描述小Hi和小Ho是一对好朋友,出生在信息化社会的他们对编程产生了莫大的兴趣,他们约定好互相帮助,在编程的学习道路上一同前进。这一天,他们遇到了一只河蟹,于是河蟹就向小Hi和小Ho提出了那个经典的问题:“小Hi和小Ho,你们能不能够判断一段文字(原串)里面是不是存在那么一些……特殊……的文字(模式串)?”小Hi和小Ho仔细思考了一下,觉得只能想到很简单的做法,但是又觉得既然河蟹先生这么

2017-03-11 19:09:17 154

转载 (转)C/C++ volatile让你看的更明白

转载一篇有关C/C++中volatile修饰符的文章,自己用VC++ 10.0测试了一下,与原文有一些不同,特论述如下,让你也让自己看的更明白。链接:http://blog.sina.com.cn/s/blog_4e345ce70100rsc7.html1. 为什么用volatile?C/C++ 中的 volatile 关键字和 const 对应,用来修饰变量,通常

2017-03-02 16:05:11 205

原创 1123. Is It a Complete AVL Tree

An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by more than one, rebalancing is

2017-02-22 19:35:45 207

原创 1119. Pre- and Post-order Traversals

Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and inorder traversal sequences, or preorder and inorder

2017-02-22 19:35:10 182

原创 1118. Birds in Forest

Some scientists took pictures of thousands of birds in a forest. Assume that all the birds appear in the same picture belong to the same tree. You are supposed to help the scientists to count the maxi

2017-02-22 19:33:57 172

原创 1117. Eddington Number

British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, he has even defined an "Eddington number", E -- that is, the maximum integer E such that it is for E

2017-02-22 19:32:55 159

原创 1116. Come on! Let's C

"Let's C" is a popular and fun programming contest hosted by the College of Computer Science and Technology, Zhejiang University. Since the idea of the contest is for fun, the award rules are funny as

2017-02-22 19:32:17 143

原创 1115. Counting Nodes in a BST

A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than or equal to the node's ke

2017-02-22 19:31:45 184

原创 1114. Family Property

This time, you are supposed to help us collect the data for family-owned property. Given each person's family members, and the estate(房产)info under his/her own name, we need to know the size of each f

2017-02-22 19:30:41 166

原创 1113. Integer Set Partition

Given a set of N (> 1) positive integers, you are supposed to partition them into two disjoint sets A1 and A2 of n1 and n2 numbers, respectively. Let S1 and S2 denote the sums of all the numbers in

2017-02-22 19:29:48 129

原创 1112. Stucked Keyboard

On a broken keyboard, some of the keys are always stucked. So when you type some sentences, the characters corresponding to those keys will appear repeatedly on screen for k times.Now given a resu

2017-02-22 19:28:54 160

原创 1110. Complete Binary Tree

Given a tree, you are supposed to tell if it is a complete binary tree.Input Specification:Each input file contains one test case. For each case, the first line gives a positive integer N (<=2

2017-02-22 19:28:21 113

原创 1108. Finding Average

The basic task is simple: given N real numbers, you are supposed to calculate their average. But what makes it complicated is that some of the input numbers might not be legal. A "legal" input is a re

2017-02-22 19:27:20 125

原创 1107. Social Clusters

When register on a social network, you are always asked to specify your hobbies in order to find some potential friends with the same hobbies. A "social cluster" is a set of people who have some of th

2017-02-22 19:26:28 128

原创 1106. Lowest Price in Supply Chain

A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on

2017-02-22 19:25:57 145

原创 1105. Spiral Matrix

#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;#define max1

2017-02-22 19:25:08 133

原创 1104. Sum of Number Segments

Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence {0.1, 0.2, 0.3, 0.4}, we have 10 segments: (0.1) (0.1, 0.2) (0.1, 0.2, 0.3)

2017-02-22 19:24:33 185

原创 1103. Integer Factorization

The K-P factorization of a positive integer N is to write N as the sum of the P-th power of K positive integers. You are supposed to write a program to find the K-P factorization of N for any positive

2017-02-22 19:23:30 151

原创 1102. Invert a Binary Tree

The following is from Max Howell @twitter:Google: 90% of our engineers use the software you wrote (Homebrew), but you can't invert a binary tree on a whiteboard so fuck off.Now it's your turn

2017-02-22 19:22:15 118

原创 1101. Quick Sort

There is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one element as the pivot. Then the elements less than the pivot are moved to its le

2017-02-22 19:21:17 128

原创 1100. Mars Numbers

People on Mars count their numbers with base 13:Zero on Earth is called "tret" on Mars.The numbers 1 to 12 on Earch is called "jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec" on Ma

2017-02-21 20:07:40 186

原创 1099. Build A Binary Search Tree

A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node's key.The right

2017-02-21 20:06:43 202

原创 1098. Insertion or Heap Sort

According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input dat

2017-02-21 20:05:42 137

原创 1097. Deduplication on a Linked List

Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each value K, only the first node of which the value or a

2017-02-21 20:05:08 164

原创 1096. Consecutive Factors

Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be factored as 3*5*6*7, where 5, 6, and 7 are the three consecutive numbers. Now given

2017-02-21 20:03:51 133

原创 1094. The Largest Generation

A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation with the largest population.Inpu

2017-02-21 20:02:25 175

原创 1093. Count PAT's

The string APPAPT contains two PAT's as substrings. The first one is formed by the 2nd, the 4th, and the 6th characters, and the second one is formed by the 3rd, the 4th, and the 6th characters.No

2017-02-21 20:01:48 211

原创 1092. To Buy or Not to Buy

Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy some beads. There were many colorful strings of beads. However the owner of the shop would only sel

2017-02-21 20:00:46 135

原创 1090. Highest Price in Supply Chain

A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on

2017-02-21 19:59:52 114

空空如也

空空如也

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

TA关注的人

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