
C++
bowen_wu_
这个作者很懒,什么都没留下…
展开
-
CONTAINER类之心得体会
其实容器类就是一个有各种容器的接口,通过C++继承与多态的特性,能够自由的往容器类中添加各种数据结构。上图就是这个容器类的基本结构。其中带箭头的线表示继承关系、带矩形的线表示组成关系、带圆形的线表示这个类是一个纯虚类(可以理解成接口)为了编码的便捷,在下面的编码中我并没有自己写排序的算法,而是调用了algorithm 中的std::sort()函数.Collection.hpp// Created原创 2016-04-17 11:38:32 · 794 阅读 · 4 评论 -
LeetCode题解系列--763. Partition Labels
描述A string S of lowercase letters is given. We want to partition this string into as many parts as possible so that each letter appears in at most one part, and return a list of integers representin原创 2018-01-18 12:24:31 · 729 阅读 · 0 评论 -
LeetCode题解系列--309. Best Time to Buy and Sell Stock with Cooldown
描述Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy原创 2018-01-18 01:00:16 · 469 阅读 · 0 评论 -
LeetCode题解系列--188. Best Time to Buy and Sell Stock IV
描述Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most k transactions.Note: You may no原创 2018-01-17 16:53:55 · 376 阅读 · 0 评论 -
LeetCode题解系列--123. Best Time to Buy and Sell Stock III
描述Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most two transactions.Note: You may原创 2018-01-17 13:33:24 · 244 阅读 · 0 评论 -
LeetCode题解系列--122. Best Time to Buy and Sell Stock II
描述Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy原创 2018-01-17 11:54:15 · 240 阅读 · 0 评论 -
LeetCode题解系列--121. Best Time to Buy and Sell Stock
描述Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock原创 2018-01-17 11:48:11 · 236 阅读 · 0 评论 -
LeetCode题解系列--714. Best Time to Buy and Sell Stock with Transaction Fee
描述Your are given an array of integers prices, for which the i-th element is the price of a given stock on day i; and a non-negative integer fee representing a transaction fee.You may complete as many t原创 2017-12-13 16:39:53 · 999 阅读 · 0 评论 -
LeetCode题解系列--712. Minimum ASCII Delete Sum for Two Strings
描述Given two strings s1, s2, find the lowest ASCII sum of deleted characters to make two strings equal.Example 1: Input: s1 = “sea”, s2 = “eat” Output: 231 Explanation: Deleting “s” from “sea” adds t原创 2017-11-02 19:52:01 · 749 阅读 · 0 评论 -
LeetCode题解系列--718. Maximum Length of Repeated Subarray
描述Given two integer arrays A and B, return the maximum length of an subarray that appears in both arrays.Example 1: Input: A: [1,2,3,2,1] B: [3,2,1,4,7] Output: 3 Explanation: The repeated subar原创 2017-11-01 21:29:40 · 2069 阅读 · 0 评论 -
LeetCode题解系列--684. Redundant Connection
描述In this problem, a tree is an undirected graph that is connected and has no cycles.The given input is a graph that started as a tree with N nodes (with distinct values 1, 2, …, N), with one additiona原创 2017-10-10 14:36:22 · 376 阅读 · 0 评论 -
LeetCode题解系列--685. Redundant Connection II
描述In this problem, a rooted tree is a directed graph such that, there is exactly one node (the root) for which all other nodes are descendants of this node, plus every node has exactly one parent, exce原创 2017-10-18 14:38:06 · 1742 阅读 · 0 评论 -
C++读取文件为何会多读一行?
近来在做概率统计的作业,由于手算均值中值什么的,还有画茎叶图太麻烦,所以写了个小程序。但是当我算到最后时却发现这个小程序有一个bug,然后就gg了。这个bug大概是这样的: 原本在data.txt中只有三个数,读到内存中却有四个数。 正确的结果应该是这样:出事的代码如下:#include <iostream>#include <fstream>#include <vector>#inclu原创 2016-09-01 16:02:16 · 6189 阅读 · 7 评论 -
C++类型转换函数(类型转换运算符函数)
转载自:http://c.biancheng.net/cpp/biancheng/view/222.html> 用转换构造函数可以将一个指定类型的数据转换为类的对象。但是不能反过来将一个类的对象转换为一个其他类型的数据(例如将一个Complex类对象转换成double类型数据)。C++提供类型转换函数(type conversion function)来解决这个问题。类型转换函数的作用是将一个类的转载 2016-05-30 00:06:51 · 379 阅读 · 0 评论 -
C++之继承
C++ 继承 语法 程序设计 软件工程若有理解不当,欢迎各位指正!作者:吴博文 中山大学数据科学与计算机学院 本人博客:http://blog.youkuaiyun.com/bowen_wu_一、继承基本概念通过继承,所构建的新的类是基于可靠的基类(base class),所以通过这种机制,可以提高代码的复用率(reuseability),从而减少新类的调试的工作量,从而提高编码的效率。同时,由于存在继承这个原创 2016-04-19 21:02:45 · 672 阅读 · 0 评论 -
习题8.15
题目Show that the following problem is NP-complete. MAXIMUM COMMON SUBGRAPH Input: Two graphs G1 = (V1, E1) and G2 = (V2, E2); a budget b. Output: Two set of nodes V1′ ⊆ V1 and V2′ ⊆ V2 whose delet翻译 2018-01-18 12:41:13 · 368 阅读 · 0 评论