11 2020 档案

摘要:从前到后遍历和从后到前遍历 使用rbegin()和rend(),反方向输出 vector<int> a = {2,3,4,5,6,7,8,9}; for(auto i = a.rbegin(); i != a.rend(); i++) cout << *i << " "; 在容器内降序排列 vect 阅读全文
posted @ 2020-11-19 23:10 晓尘 阅读(260) 评论(0) 推荐(0) 编辑
摘要:归并排序 O(nlogan) 主要思想 分治 快排是用一个数来分,让左边都小于等于这个数,右面都大于等于这个数。 归并是以整个数组最中心来分。 具体步骤 确定分界点mid即下标长度中间值,取左右平均值(l+r)2即可 递归排序左边left和右边right 归并: 阅读全文
posted @ 2020-11-17 20:02 晓尘 阅读(84) 评论(0) 推荐(0) 编辑
摘要:原题链接:打印沙漏 思路 我们可以知道打印的沙漏是对称的,假如输入19个*,实际只会用17个,有两个被舍弃了。 那么我们可以发现一半行数的数量加一起就是19/2个,又可以发现一个规律: 1 = 1 1+3 = 22 1+3+5 = 32 所谓行数的一半恰好就是n阅读全文
posted @ 2020-11-16 23:12 晓尘 阅读(125) 评论(0) 推荐(0) 编辑
摘要:用于查找目标字符串的find函数 在库中 查找从指定位置开始的第一次出现的目标字符串:必须所有元素都相同 #include<iostream> #include<cstdio> using namespace std; int main(){ string s1 = "abcdef"; string 阅读全文
posted @ 2020-11-11 13:47 晓尘 阅读(678) 评论(0) 推荐(0) 编辑
摘要:初始化Vector 初始化一个为{1,2,3,4,5,6,7}的Vector数组 vector<int> a = {1,2,3,4,5,6,7} 初始化一个有10个元素且所有元素都为2的Vector数组 vector<int> a(10, 2); 初始化一个大小为100值不确定的vector数组 v 阅读全文
posted @ 2020-11-11 13:14 晓尘 阅读(123) 评论(0) 推荐(0) 编辑
摘要:STL标准库查找函数 find函数 二分查找,binary_search函数 目的:查找某元素是否存在于数组,存在返回1,不存在返回0. binary_search(arr[],arr[]+size,target) arr[]:数组首地址 size:数组元素个数 target:查找的元素 lower 阅读全文
posted @ 2020-11-09 20:40 晓尘 阅读(89) 评论(0) 推荐(0) 编辑
摘要:https://pintia.cn/problem-sets/994805260223102976/problems/994805300404535296 #include<iostream> #include <map> using namespace std; const int N = 101 阅读全文
posted @ 2020-11-06 22:27 晓尘 阅读(76) 评论(0) 推荐(0) 编辑

阅读目录(Content)

此页目录为空

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