随笔分类 -  C/C++

摘要:10^9以下用int,10^18以下用long long。 C++代码如下 #include<iostream> #include<string> #include <limits> using namespace std; int main() { cout << "type: \t\t\t" < 阅读全文
posted @ 2020-08-11 21:14 程序员曾奈斯 阅读(1227) 评论(0) 推荐(0) 编辑
摘要:实现对vector的截段操作。 C++版本 #include <iostream> #include <vector> int main() { vector<int> vector{1,2,3,4,5,6,7,8,9}; cout << "vectoor: "; for(auto el : vec 阅读全文
posted @ 2020-07-28 20:12 程序员曾奈斯 阅读(9868) 评论(0) 推荐(0) 编辑
摘要:指针的基本知识 C++版 #include <iostream> #include <algorithm> using namespace std; int main() { char ch[6] = "hello"; char* pch = ch; // char数组可以用指针来修改 pch[0] 阅读全文
posted @ 2020-07-26 10:35 程序员曾奈斯 阅读(555) 评论(0) 推荐(0) 编辑
摘要:引用字符串或者使用字符串函数 注意,在C++中,#include<string>与#include<ctring>和#include<string.h>是不一样的。 使用C中的字符串函数比如strlen(),需要引入的是#include<ctring>或者#include<string.h> 使用字 阅读全文
posted @ 2020-07-22 15:27 程序员曾奈斯 阅读(488) 评论(0) 推荐(0) 编辑
摘要:剑指offer版本 创建一个结点 链接两个结点(链表) 打印某个结点的值 打印pHead之后的链表 销毁pHead之后的链表 // // 《剑指Offer——名企面试官精讲典型编程题》代码 // 作者:何海涛 // // 面试题6:从尾到头打印链表 // 题目:输入一个链表的头结点,从尾到头反过来打 阅读全文
posted @ 2020-07-10 14:30 程序员曾奈斯 阅读(1563) 评论(0) 推荐(0) 编辑
摘要:最近开始刷《剑指offer》的题目,发现好多问题都需要用到指针。所以又来捡起指针的知识。。。 一. 底层理解“变量” 1.1 变量的实质 理解指针,就需要理解“变量”的存储实质。如下图所示,变量存储在一段连续的内存中,旁边儿的十六进制数,即为变量在内存中的“地址”。 当我们在程序中写下了这样的语言声 阅读全文
posted @ 2020-06-04 11:11 程序员曾奈斯 阅读(152) 评论(0) 推荐(0) 编辑
摘要:int main() { char * pArray[] ={"apple","pear","banana","orange","pineApple"}; std::cout << sizeof(pArray) << std::endl; std::cout << sizeof(pArray[1]) 阅读全文
posted @ 2020-06-03 22:21 程序员曾奈斯 阅读(136) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示