随笔分类 -  C++

2016.5.24——Intersection of Two Linked Lists
摘要:Intersection of Two Linked Lists 本题收获: 1.链表的输入输出 2.交叉链表:这个链表可以有交叉点,只要前一个节点的的->next相同即可。 题目:Intersection of Two Linked Lists Write a program to find th 阅读全文

posted @ 2016-05-25 20:13 zhuzhu2016 阅读(173) 评论(0) 推荐(0)

2016.5.25——链表初始化及输出
摘要:链表初始化及输出 刷lleetcode题时不会写mian函数,于是把链表的几种输出总结一下。 阅读全文

posted @ 2016-05-25 16:13 zhuzhu2016 阅读(212) 评论(0) 推荐(0)

2016.5.21——atoi()函数的测试
摘要:对函数atoi()函数的测试: atoi()函数将字符串型转换为整型 代码: 注意定义字符串型时不能定义成string,而要定义为char型。否则出错:error C2664: “int atoi(const char *)”: 无法将参数 1 从“std::string [1]”转换为“const 阅读全文

posted @ 2016-05-22 11:52 zhuzhu2016 阅读(286) 评论(0) 推荐(0)

2016.5.21——Compare Version Numbers
摘要:Compare Version Numbers 本题收获: 1.字符串型数字转化为整型数字的方法:s[i] - '0',( 将字母转化为数字是[i]-'A' ) 2.srt.at(),substr(),atoi() 3.字符串型数组的定义:string str[3]={“aaaa”,"bbbb"," 阅读全文

posted @ 2016-05-21 23:22 zhuzhu2016 阅读(219) 评论(0) 推荐(0)

2016.5.19——Excel Sheet Column Title
摘要:Excel Sheet Column Title 本题收获: 1.由int型转换为整型(string),如何转化, res = 'A'+(n-1)%26和之前由A-z转化为十进制相反,res = s[i]-'A'+1.(为什么有+1,-1还有点迷糊,貌似是十进制是0-9,26进制是) 2.十进制到2 阅读全文

posted @ 2016-05-19 23:00 zhuzhu2016 阅读(198) 评论(0) 推荐(0)

2016.5.18——leetcode:Majority Element
摘要:Majority Element 本题收获: 1.初步了解hash,nth_element的用法 2.题目的常规思路 题目: Given an array of size n, find the majority element. The majority element is the elemen 阅读全文

posted @ 2016-05-19 14:39 zhuzhu2016 阅读(160) 评论(0) 推荐(0)

2016.5.18——Excel Sheet Column Number
摘要:Excel Sheet Column Number 本题收获: 1.对于字符串中字母转为ASIIC码:string s ;res = s[i]-'A'; 这个res就是数字s[i]-'A'是对ASIIC的操作。 2.对于进制的转换:利用for循环 ,%,/,数组在完成。 3.2中的数组都是从左到右的 阅读全文

posted @ 2016-05-18 22:33 zhuzhu2016 阅读(299) 评论(0) 推荐(0)

2016.5.17——数组的定义
摘要:数组的定义 学到的: 1.数组如何定义: 主要有两种: 数组:int a[5]; int a[]={1,2,3} 数组型时要有大小和内容至少一个。 指针:*a 指向数组的第一个元素的地址 如何创建动态数组:int *a; a = new int[n]; 或者 int *a = new int[n]; 阅读全文

posted @ 2016-05-18 20:38 zhuzhu2016 阅读(190) 评论(0) 推荐(0)

2016.5.17——数组的输入输出
摘要:数组的输入输出 本次收获: 1.int型数组输入输出 都需要用一个for循环,char型则不用。 1.char型在编辑器输入中的多种方法。 3.如何创建动态数组:int *a; a = new int[n]; 或者 int *a = new int[n];注意数组的定义。 代码1:int型数组的输入 阅读全文

posted @ 2016-05-18 20:26 zhuzhu2016 阅读(490) 评论(0) 推荐(0)

2016.5.16——leetcode:Rotate Array,Factorial Trailing Zeroe
摘要:Rotate Array 本题目收获: 题目: Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated 阅读全文

posted @ 2016-05-17 09:32 zhuzhu2016 阅读(216) 评论(0) 推荐(0)

2016.5.16——leetcode:Reverse Bits(超详细讲解)
摘要:leetcode:Reverse Bits 本题目收获 移位(<< >>), 或(|),与(&)计算的妙用 题目: Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represen 阅读全文

posted @ 2016-05-16 10:07 zhuzhu2016 阅读(517) 评论(0) 推荐(0)

2016.5.15——leetcode:Number of 1 Bits ,
摘要:leetcode:Number of 1 Bits 代码均测试通过! 1.Number of 1 Bits 本题收获: 1.Hamming weight:即二进制中1的个数 2.n &= (n-1)【n = n & (n-1)】的用处 题目: Write a function that takes 阅读全文

posted @ 2016-05-15 17:42 zhuzhu2016 阅读(200) 评论(0) 推荐(0)

2016.5.14——leetcode-HappyNumber,House Robber
摘要:leetcode:HappyNumber,House Robber 1.Happy Number 这个题中收获2点: 1.拿到题以后考虑特殊情况,代码中考虑1和4,或者说<6的情况,动手算下。(可能要在代码一步步测试中发现,目前还不知道怎么知道这些特殊情况) 2.数字的每一位时,n%10,n/10。 阅读全文

posted @ 2016-05-15 15:37 zhuzhu2016 阅读(254) 评论(0) 推荐(0)

导航