会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
天凉好个秋秋
博客园
首页
新随笔
联系
管理
订阅
随笔分类 -
机试指南
快速排序
摘要:#include <stdio.h> #include <iostream> //对 arr[l……r]进行处理 //返回 p , arr[l……p-1] < arr[p] < arr[p + 1……r] template <typename T> int __partition(T arr[],i
阅读全文
posted @
2020-06-10 11:29
天凉好个秋秋
阅读(88)
评论(0)
推荐(0)
由先序遍历+中序遍历推出后序遍历
摘要:#include <iostream> #include <cstdio> #include <algotithm> using namespace std; struct TreeNode{ char data; TreeNode* leftChild; TreeNode* rightChild;
阅读全文
posted @
2020-05-27 21:35
天凉好个秋秋
阅读(768)
评论(0)
推荐(0)
vector
摘要:#include <cstdio> #include <iostream> #include <vector> using namespace std; int main(){ int n,min,max; vector<int> number; number.insert(number.end()
阅读全文
posted @
2020-05-25 22:20
天凉好个秋秋
阅读(102)
评论(0)
推荐(0)
字符串——首字符大写
摘要:#include <stdio.h> #include <iostream> #include <string> #include <cstring> using namespace std; int main(){ string str; getline(cin,str); for(int i =
阅读全文
posted @
2020-05-25 15:21
天凉好个秋秋
阅读(184)
评论(0)
推荐(0)
字符串——字符串统计
摘要:#include <stdio.h> #include <iostream> #include <string> #include <cstring> using namespace std; //统计第一行字符串在第二行中出现的次数 //先遍历第二行,每个元素的次数 //然后遍历第一行,看看 in
阅读全文
posted @
2020-05-25 14:55
天凉好个秋秋
阅读(260)
评论(0)
推荐(0)
字符串——明文加密
摘要:#include <string> #include <iostream> //循环加密 int main(){ string str; //获取一行输入,getline(输入方式,存入哪里) while(getline(cin,str)){ //遇到特定输入,跳出循环 if(str == "END
阅读全文
posted @
2020-05-25 14:54
天凉好个秋秋
阅读(360)
评论(0)
推荐(0)
判断素数
摘要:329 = 3 1 * 3 4 * 38 * 316 1.一个质数的判断 bool judge(int n){ if(n < 2){ return false; } int bound = sqrt(n); for(int i = 0;i < bound;i++){ if(n % i == 0){
阅读全文
posted @
2020-05-19 15:13
天凉好个秋秋
阅读(158)
评论(0)
推荐(0)
最大公约数
摘要:#include <cstdio> #include <cstring> #include <algorithm> #include <iostream> #include <cmath> #include <vector> using namespace std; //非递归形式 void gcl
阅读全文
posted @
2020-05-16 17:07
天凉好个秋秋
阅读(114)
评论(0)
推荐(0)
排序
摘要:输入50个正整数,将其中的偶数按升序排列,奇数按降序排列。若偶数个数多于奇数个数,则偶数放在数组的前边,奇数放在其后;否则奇数放在前,偶数在后;输出排序后的结果。 #include <iostream> #include <cstdio> #include <algorithm> /** * 奇数在
阅读全文
posted @
2020-05-16 16:55
天凉好个秋秋
阅读(163)
评论(0)
推荐(0)
数学问题——十进制转N进制
摘要:#include <cstdio> #include <cstring> #include <algorithm> #include <iostream> #include <vector> using namespace std; char intToChar(int n){ if(n < 10)
阅读全文
posted @
2020-05-15 20:43
天凉好个秋秋
阅读(213)
评论(0)
推荐(0)
贪心算法
摘要:贪心策略 贪心算法是指在对问题求解时,总是做出在当前看来是最好的选择。也就是说,不从整体最优上加以考虑,它所做出的仅是在某种意义上的局部最优解。用局部解构造全局解,即从问题的某一个初始解逐步逼近给定的目标,以尽可能快的求得更好的解。当某个算法中的某一步不能再继续前进时,算法停止。 贪心策略:将问题分
阅读全文
posted @
2020-05-14 09:53
天凉好个秋秋
阅读(205)
评论(0)
推荐(0)
栈的应用(一)——括号的匹配
摘要:#include <cstring> #include <cstdio> #include <iostream> #include <stack> using namespace std; int main(){ string str; while(cin >> str){ stack<int> b
阅读全文
posted @
2020-04-18 15:40
天凉好个秋秋
阅读(145)
评论(0)
推荐(0)
猫狗收养问题
摘要:问题描述 链接:https://www.nowcoder.com/questionTerminal/6235a76b1e404f748f7c820583125c50?f=discussion来源:牛客网 有家动物收容所只收留猫和狗,但有特殊的收养规则,收养人有两种收养方式,第一种为直接收养所有动物中
阅读全文
posted @
2020-04-17 15:52
天凉好个秋秋
阅读(273)
评论(0)
推荐(0)
字符串
摘要:一、理论知识 构造,操作,运算,函数 1.构造 2.操作 遍历 insert erase 1)从19号下标全部不要了 2)从 0-9 删除 3.运算 拼接 + 比较大小 4.函数 字符串长度 size str.size(); 查找 find 字符串截取 substr substr 二、应用一——遍历
阅读全文
posted @
2020-04-13 22:14
天凉好个秋秋
阅读(95)
评论(0)
推荐(0)
查找
摘要:1.线性查找 2. 二分查找:自定义的 和系统自带的 系统自带的:lower_bound 返回大于或等于目标值的第一个位置。 upper_bound 返回大于目标值的第一个位置。
阅读全文
posted @
2020-04-05 11:13
天凉好个秋秋
阅读(90)
评论(0)
推荐(0)
利用归并排序求逆序数
摘要:
阅读全文
posted @
2020-04-04 11:42
天凉好个秋秋
阅读(119)
评论(0)
推荐(0)
线性排序-计数排序
摘要:#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> using namespace std; //给你n个整数,请按从大到小的顺序输出前m大的数 //定义一个辅助数组,数组下标是原数组的数字, c
阅读全文
posted @
2020-04-02 19:03
天凉好个秋秋
阅读(141)
评论(0)
推荐(0)
排序
摘要:必备知识 1.排序用的函数 sort 2. 引入头部文件 #include <alogrithm> 3.自定义类型函数重写 4.运算符重载 案例一 整数奇数偶数排序 #include <iostream> #include <cstdio> #include <algorithm> /** * 奇数
阅读全文
posted @
2020-04-01 21:29
天凉好个秋秋
阅读(131)
评论(0)
推荐(0)
公告