《剑指offer》第二版 高清PDF+代码附赠 64M PDF文档
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2518 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2.gitattributes
文件 3833 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2.gitignore
文件 7160 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 1_AssignmentOperator 1_AssignmentOperator.vcxproj
文件 949 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 1_AssignmentOperator 1_AssignmentOperator.vcxproj.filters
文件 2798 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 1_AssignmentOperatorAssignmentOperator.cpp
文件 2626 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 2_Singleton 2_Singleton.csproj
文件 184 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 2_SingletonApp.config
文件 3573 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 2_SingletonProgram.cs
文件 1400 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 2_SingletonPropertiesAssemblyInfo.cs
文件 7126 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 3_01_DuplicationInArray 3_01_DuplicationInArray.vcxproj
文件 946 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 3_01_DuplicationInArray 3_01_DuplicationInArray.vcxproj.filters
文件 4182 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 3_01_DuplicationInArrayFindDuplication.cpp
文件 7138 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 3_02_DuplicationInArrayNoEdit 3_02_DuplicationInArrayNoEdit.vcxproj
文件 952 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 3_02_DuplicationInArrayNoEdit 3_02_DuplicationInArrayNoEdit.vcxproj.filters
文件 4818 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 3_02_DuplicationInArrayNoEditFindDuplicationNoEdit.cpp
文件 7144 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 4_FindInPartiallySortedMatrix 4_FindInPartiallySortedMatrix.vcxproj
文件 958 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 4_FindInPartiallySortedMatrix 4_FindInPartiallySortedMatrix.vcxproj.filters
文件 3471 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 4_FindInPartiallySortedMatrixFindInPartiallySortedMatrix.cpp
文件 7116 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 5_ReplaceSpaces 5_ReplaceSpaces.vcxproj
文件 944 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 5_ReplaceSpaces 5_ReplaceSpaces.vcxproj.filters
文件 3650 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 5_ReplaceSpacesReplaceSpaces.cpp
文件 7319 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 6_PrintListInReversedOrder 6_PrintListInReversedOrder.vcxproj
文件 955 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 6_PrintListInReversedOrder 6_PrintListInReversedOrder.vcxproj.filters
文件 2329 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 6_PrintListInReversedOrderPrintListInReversedOrder.cpp
文件 7309 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 7_ConstructBinaryTree 7_ConstructBinaryTree.vcxproj
文件 950 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 7_ConstructBinaryTree 7_ConstructBinaryTree.vcxproj.filters
文件 5285 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 7_ConstructBinaryTreeConstructBinaryTree.cpp
文件 7313 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 8_NextNodeInBinaryTrees 8_NextNodeInBinaryTrees.vcxproj
文件 952 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 8_NextNodeInBinaryTrees 8_NextNodeInBinaryTrees.vcxproj.filters
文件 6085 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 8_NextNodeInBinaryTreesNextNodeInBinaryTrees.cpp
............此处省略320个文件信息
/*******************************************************************
Copyright(c) 2016 Harry He
All rights reserved.
Distributed under the BSD license.
(See accompanying file LICENSE.txt at
https://github.com/zhedahht/CodingInterviewChinese2/blob/master/LICENSE.txt)
*******************************************************************/
//==================================================================
// 《剑指Offer——名企面试官精讲典型编程题》代码
// 作者:何海涛
//==================================================================
// 面试题1:赋值运算符函数
// 题目:如下为类型CMyString的声明,请为该类型添加赋值运算符函数。
#include
#include
class CMyString
{
public:
CMyString(char* pData = nullptr);
CMyString(const CMyString& str);
~CMyString(void);
CMyString& operator = (const CMyString& str);
void Print();
private:
char* m_pData;
};
CMyString::CMyString(char *pData)
{
if(pData == nullptr)
{
m_pData = new char[1];
m_pData[0] = ‘ ‘;
}
else
{
int length = strlen(pData);
m_pData = new char[length + 1];
strcpy(m_pData pData);
}
}
CMyString::CMyString(const CMyString &str)
{
int length = strlen(str.m_pData);
m_pData = new char[length + 1];
strcpy(m_pData str.m_pData);
}
CMyString::~CMyString()
{
delete[] m_pData;
}
CMyString& CMyString::operator = (const CMyString& str)
{
if(this == &str)
return *this;
delete []m_pData;
m_pData = nullptr;
m_pData = new char[strlen(str.m_pData) + 1];
strcpy(m_pData str.m_pData);
return *this;
}
// ====================测试代码====================
void CMyString::Print()
{
printf(“%s“ m_pData);
}
void Test1()
{
printf(“Test1 begins:
“);
char* text = “Hello world“;
CMyString str1(text);
CMyString str2;
str2 = str1;
printf(“The expected result is: %s.
“ text);
printf(“The actual result is: “);
str2.Print();
printf(“.
“);
}
// 赋值给自己
void Test2()
{
printf(“Test2 begins:
“);
char* text = “Hello world“;
CMyString str1(text);
str1 = str1;
printf(“The expected result is: %s.
“ text);
printf(“The actual result is: “);
str1.Print();
printf(“.
“);
}
// 连续赋值
void Test3()
{
printf(“Test3 begins:
“);
char* text = “Hello world“;
CMyString str1(text);
CMyString str2 str3;
str3 = str2 = str1;
printf(“The expected result is: %s.
“ text);
printf(“The actual result is: “);
str2.Print();
printf(“.
“);
printf(“The expected result is: %s.
“ text);
printf(“The actual result is: “);
str3.Print();
printf(“.
“);
}
int main(int argc char* argv[])
{
Test1();
Test2();
Test3();
return 0;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2518 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2.gitattributes
文件 3833 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2.gitignore
文件 7160 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 1_AssignmentOperator 1_AssignmentOperator.vcxproj
文件 949 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 1_AssignmentOperator 1_AssignmentOperator.vcxproj.filters
文件 2798 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 1_AssignmentOperatorAssignmentOperator.cpp
文件 2626 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 2_Singleton 2_Singleton.csproj
文件 184 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 2_SingletonApp.config
文件 3573 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 2_SingletonProgram.cs
文件 1400 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 2_SingletonPropertiesAssemblyInfo.cs
文件 7126 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 3_01_DuplicationInArray 3_01_DuplicationInArray.vcxproj
文件 946 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 3_01_DuplicationInArray 3_01_DuplicationInArray.vcxproj.filters
文件 4182 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 3_01_DuplicationInArrayFindDuplication.cpp
文件 7138 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 3_02_DuplicationInArrayNoEdit 3_02_DuplicationInArrayNoEdit.vcxproj
文件 952 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 3_02_DuplicationInArrayNoEdit 3_02_DuplicationInArrayNoEdit.vcxproj.filters
文件 4818 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 3_02_DuplicationInArrayNoEditFindDuplicationNoEdit.cpp
文件 7144 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 4_FindInPartiallySortedMatrix 4_FindInPartiallySortedMatrix.vcxproj
文件 958 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 4_FindInPartiallySortedMatrix 4_FindInPartiallySortedMatrix.vcxproj.filters
文件 3471 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 4_FindInPartiallySortedMatrixFindInPartiallySortedMatrix.cpp
文件 7116 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 5_ReplaceSpaces 5_ReplaceSpaces.vcxproj
文件 944 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 5_ReplaceSpaces 5_ReplaceSpaces.vcxproj.filters
文件 3650 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 5_ReplaceSpacesReplaceSpaces.cpp
文件 7319 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 6_PrintListInReversedOrder 6_PrintListInReversedOrder.vcxproj
文件 955 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 6_PrintListInReversedOrder 6_PrintListInReversedOrder.vcxproj.filters
文件 2329 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 6_PrintListInReversedOrderPrintListInReversedOrder.cpp
文件 7309 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 7_ConstructBinaryTree 7_ConstructBinaryTree.vcxproj
文件 950 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 7_ConstructBinaryTree 7_ConstructBinaryTree.vcxproj.filters
文件 5285 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 7_ConstructBinaryTreeConstructBinaryTree.cpp
文件 7313 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 8_NextNodeInBinaryTrees 8_NextNodeInBinaryTrees.vcxproj
文件 952 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 8_NextNodeInBinaryTrees 8_NextNodeInBinaryTrees.vcxproj.filters
文件 6085 2018-03-05 17:23 剑指offer第二版CodingInterviewChinese2 8_NextNodeInBinaryTreesNextNodeInBinaryTrees.cpp
............此处省略320个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)