![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
文章平均质量分 58
清空的代码
这个作者很懒,什么都没留下…
展开
-
标准C++中的string类的用法总结
要想使用标准C++中string类,必须要包含#include // 注意是,不是,带.h的是C语言中的头文件using std::string;using std::wstring;或using namespace std;下面你就可以使用string/wstring了,它们两分别对应着char和wchar_t。转载 2015-10-22 21:14:39 · 891 阅读 · 0 评论 -
C++访问控制
在c++中有三种访问控制说明符:public 、protected 、private一、访问类中成员情况:private: 只允许类内成员函数和友元函数访问,不允许类的对象访问;protected:只允许类内成员函数、子类内成员函数和友元函数访问,不允许类的对象访问;public: 允许类内成员函数、子类内成员函数、友元函数和类的对象访问。二、继承中的情况:priv原创 2016-04-12 13:47:25 · 467 阅读 · 0 评论 -
C++ STL 中lower_bound() 和 upper_bound()讲解
1、lower_bound()在有序的范围内(具有大于或等于指定值的值)查找第一个元素的位置,该排序标准可由二进制谓词指定。 语法: template ForwardIterator lower_bound( ForwardIterator first, ForwardIterator last, const Type& valu原创 2016-03-29 23:24:57 · 13152 阅读 · 0 评论 -
罗马数字转换成阿拉伯数字
罗马数字采用七个罗马字母作数字、即Ⅰ(1)、V(5)、X(10)、L(50)、C(100)、D(500)、M(1000)。记数的方法:1、相同的数字连写,所表示的数等于这些数字相加得到的数,如 Ⅲ=3;2、小的数字在大的数字的右边,所表示的数等于这些数字相加得到的数,如 Ⅷ=8、Ⅻ=12;3、小的数字(限于 Ⅰ、X 和 C)在大的数字的左边,所表示的数等于大数减小数得到的数,如原创 2015-10-28 22:51:23 · 893 阅读 · 0 评论 -
两个vector相连接--vector.insert用法
两个vector连接比如,现在有两个vector类型的两个变量a,b其中a = [1,2,5] , b = [4,7,9],如果想要将a,b两个变量连接合成[1,2,5,4,7,9],则用vector的insert属性即可如果在a后面插入b,则方法为a.insert(a.end(),b,begin(),b.end());如果在a的前面插入b,则方法为a.in原创 2016-03-04 07:54:54 · 21768 阅读 · 0 评论 -
[leetcode319] Bulb Switcher--判断约数的个数的奇偶性
Question:There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it's off原创 2016-03-03 22:15:45 · 811 阅读 · 0 评论 -
[leetcode 155] Min Stack
Question:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stac原创 2015-12-21 23:00:25 · 375 阅读 · 0 评论 -
[leetcode 311] Sparse Matrix Multiplication
Question:Given two sparse matrices A and B, return the result of AB.You may assume that A's column number is equal to B's row number.Example:A = [ [ 1, 0, 0], [-1, 0, 3]原创 2015-12-29 22:45:36 · 2749 阅读 · 0 评论 -
[leetcode 136] Single Number
Question:Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it wi原创 2015-12-28 22:35:22 · 495 阅读 · 0 评论 -
[leetcode 290] Word Pattern
Question:Given a pattern and a string str, find if str follows the same pattern.Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty原创 2015-11-26 21:56:36 · 784 阅读 · 0 评论 -
sunday算法介绍 【字符串模式匹配】
字符串匹配--sunday 算法听说这个算法比kmp效率还高,而且重要的是还好理解,所以就.....好了,sunday算法还真的很好理解,用下面的例子来说明吧: j k原创 2015-12-10 21:39:48 · 473 阅读 · 0 评论 -
ctype.h中的关于字符判断
isalpha函数名称: isalpha函数原型: int isalpha(char ch);函数功能: 检查ch是否是字母.函数返回: 是字母返回非0 ,否则返回 0.参数说明:所属文件 iscntrl函数名称: iscntrl函数原型: int iscntrl(int ch);函数功能: 检查ch是否控制字符(其ASCII原创 2015-12-10 22:58:37 · 1086 阅读 · 0 评论 -
[leetcode 246] Strobogrammatic Number
Question:A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).Write a function to determine if a number is strobogrammatic. The number is rep原创 2015-11-01 12:06:14 · 1146 阅读 · 0 评论 -
[leetcode 7] Reverse Integer
Question:Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321分析:倒置整形数字,借用字符串,因为可以通过atoi,atol,atoll,atof,strtod,strtol,strtoul等函数将字符串转换为数字;按顺序原创 2015-12-09 11:06:44 · 333 阅读 · 0 评论 -
[leetcode 219] Contains Duplicate II
Question:Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and j is at most k原创 2015-11-13 23:02:41 · 326 阅读 · 0 评论 -
[leetcode 252] Meeting Rooms
Problem Description:Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si For example,Given [[0, 30],[5, 10],[15, 20]],return false.原创 2015-10-27 23:07:07 · 1244 阅读 · 0 评论 -
C++ STL 排序(Sort)
9转载 2015-10-24 11:52:20 · 1008 阅读 · 0 评论 -
vector.erase()用法介绍及注意事项;
vector::erase():从指定容器删除指定位置的元素或某段范围内的元素vector::erase()方法有两种重载形式如下:iterator erase( iterator _Where);删除指定位置的元素,返回值是一个迭代器,指向删除元素的下一个元素;iterator erase( iterator _First, ite原创 2015-10-24 09:23:33 · 23496 阅读 · 4 评论 -
memset()函数用法简介
void *memset(void *s, int ch, size_t n);函数解释:将s中前n个字节 (typedef unsigned int size_t )用 ch 替换并返回 s 。memset:作用是在一段内存块中填充某个给定的值,它是对较大的结构体或数组进行清零操作的一种最快方法。memset是计算机中C/C++语言函数。将s所指向的某一块内存中的前n个 字节原创 2016-04-14 13:03:00 · 947 阅读 · 0 评论