- 博客(16)
- 收藏
- 关注
原创 多文件编译相关问题
多文件编译问题问题引入1.由const或static修饰的全局变量,只能在该文件中访问?可以通过文件包含的方式访问吗?答:一个全局变量的作用域默认是整个程序, 加了static 或者加了 const 的全局变量的作用域则是这个源文件,但是可以通过文件包含的方式进行访问,不过作用域也仅限在该源文件中。2.多个文件能不能同时包含一个相同的文件?答:可以。头文件与文件包含的作用见下文。3.#ifndef的作用是什么?答:防止多重定义。若头文件只有声明,多次包含是可以的,因为一个变量可以声明多次,但是
2020-08-02 10:36:31
445
原创 C++标准模板库——numeric algorithms
#include<iostream>#include<numeric>#include<vector>using namespace std;/* * 本文介绍模板库中的Numeric algorithms* -accumulate,inner product,partial sum,adjacent difference */int mai...
2020-04-26 11:05:15
220
原创 C++标准模板库——sorted data algorithms
#include<iostream>#include<algorithm>#include<vector>using namespace std;/* * 本文介绍模板库的对于已排好序的数据的算法应用* algoritms needs data being pre-sorted.* -binary search,merge,set operat...
2020-04-26 09:43:56
231
原创 C++标准模板库——排序 sorting
#include<iostream>#include<algorithm>#include<vector>using namespace std;bool lsb_less(int x,int y);bool lessThan10(int i);/* * 本文介绍模板库的排序算法* sorting algorithm requires rand...
2020-04-26 09:43:13
371
原创 C++标准模板库——order-changing algorithms
#include<iostream>#include<algorithm>#include<vector>using namespace std;/* * 本文介绍会改变元素顺序的模板库算法* order-changing algorithm - change the element's order* -reverse,rotate,permut...
2020-04-25 21:47:41
217
原创 C++标准模板库——modifying algorithms
#include<iostream>#include<algorithm>#include<vector>using namespace std;/* * 本文介绍会改变元素值的标准模板库算法* value-changing algorithm - change the element values* copy,move,transform,sw...
2020-04-25 21:33:22
132
原创 C++标准模板库——non-modifying algorithms
#include<iostream>#include<vector>#include<algorithm>using namespace std;/* * STL Algorithm walkthrough* Non-modifying Algorithms*--- count,min,max,compare,linear search,attri...
2020-04-25 16:51:06
182
原创 C++标准模板库——内置算法 algorithms
#include<iostream>#include<vector>#include<algorithm>using namespace std;bool isOdd(int i);void add2(int& i);/* * Algorithms* —— mostly loops */int main(){ vector&...
2020-04-25 16:50:33
252
原创 C++标准模板库——迭代器 iterators
#include<iostream>#include<vector>#include<list>#include<forward_list>#include<set>#include<map>using namespace std;/* * Iterators */int main(){ //? ...
2020-04-25 16:49:43
165
原创 C++标准模板库——容器适配器 container adaptor
#include<iostream>#include<queue>#include<stack>using namespace std;/* * 容器适配器 container adaptor* 1.stack: LIFO,push(),pop(),top()* 2.queue: FIFO,push(),pop(),front(),back()...
2020-04-25 16:48:51
259
原创 C++标准模板库——无序型容器 unordered assotiative containers
#include<iostream>#include<unordered_set>#include<unordered_map>#include<vector>using namespace std;void foo(const unordered_map<char,string>& m);/* *无序关联容器与关...
2020-04-25 16:48:02
141
原创 C++标准模板库——关联型容器 assotiative containers
#include<iostream>#include<set>#include<map>using namespace std;/* * set, multiset, map, multimap 是一种非线性的树结构,具体的说采用的是一种比较高效的特殊的平衡检索二叉树——红黑树结构。* 因为关联容器的这四种容器类都使用同一原理,所以他们核心的算法...
2020-04-25 16:47:22
225
原创 C++标准模板库——顺序性容器 sequence containers
#include<iostream>//STL Headers#include<vector>#include<deque>#include<list>#include<set> //set and multiset#include<map> //map and multimap#include<unord...
2020-04-25 16:46:17
399
原创 标准模板库STL概述
#include<iostream>using namespace std;/* * STL:Standard Template Libarary* ————Data Structure and Algorithms* 标准模板库中包括:容器(containers)、迭代器(Iterator)、算法(Algorithm)* 其中迭代器连接着容器与算法,容器即数据结构。为了...
2020-04-25 16:44:33
131
原创 C语言指针用法总结——指针与字符串
指针与字符串总结字符数组、字符串、字符串的函数以及字符串与指针,并自己写了一些string函数。指针就是内存地址,每一个存储单元都有一个32位编码的内存地址,指针指向某一变量,即把该变量的内存地址赋值给该指针字符串:以’\0’结尾的字符数组就是字符串。```c#include<stdio.h>#include<string.h>char *mystrcpy(...
2020-02-29 12:23:39
621
原创 C语言指针用法总结——指针与数组
指针与数组指针就是内存地址,每一个存储单元都有一个32位编码的内存地址,指针指向某一变量,即把该变量的内存地址赋值给该指针首地址:一段内存空间中第一个存储单元的地址。存储单元指针变量的加减,以指针所指向的类型空间为单位进行偏移。```c#include<stdio.h>int main(){ //一维数组与指针 // 1. 定义一个一维数组,数组名...
2020-02-29 10:17:23
344
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人