
C++
YGLeeeon
这个作者很懒,什么都没留下…
展开
-
开发中如何使用 ASan 检测内存错误
使用asan,c/c++常用分析工具转载 2022-05-08 19:37:08 · 177 阅读 · 0 评论 -
Codeforces Global Round 16:B. MIN-MEX Cut
Exampleinput601111101100101000001010output102112---------------------------------------------------------------------------------ac,有优化空间:#include <iostream>#include <sstream>#include <vector>#include &...原创 2021-09-15 19:01:31 · 277 阅读 · 3 评论 -
Codeforces Global Round 16: A. Median Maximization
A. Median Maximizationtime limit per test:1 secondmemory limit per test:256 megabytesinput:standard inputoutput:standard outputYou are given two positive integersnnandss. Find the maximum possible median of an array ofnnnon-negativeintegers...原创 2021-09-15 13:52:37 · 403 阅读 · 0 评论 -
斐波那契数—递归方法的优化
现在说一下递归求解斐波那契数,直接模拟递推公式递推公式Fn=F(n-1)+F(n-2)(n>=2,n∈N*)long long func(int n) { if (n == 1 || n == 2) { return 1; } return func(n - 1) + func(n - 2);}但是说一下使用递归求解的最常见问题:1、出现冗余程序分支 2、对...原创 2019-09-30 21:07:48 · 3085 阅读 · 3 评论 -
codeforces#588 A.Dawid and Bags of Candies B.Ania and MinimizingTable
#include <iostream>#include <vector>#include <string>#include <algorithm>using namespace std;int main() { vector<int> in_data(4,0); int i = 0; while (i<4...原创 2019-09-27 00:40:06 · 351 阅读 · 0 评论 -
笔试题
思科-字符串格式解析(用例:输入“%22Cisco%22Cisco%22<***@***.com>”输出:Cisco%22Cisco)void cisco_api() { string input; string sub_str0; cin >> input; int pos_a, pos_b; pos_a = input.find("\""); pos_...原创 2019-09-26 22:39:42 · 185 阅读 · 0 评论 -
使用递归进行链表合并
leetcode上有合并链表的题,大概是说将k个升序链表合成1个升序链表。(附上原题)将两个有序链表合并为一个新的有序链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。示例:输入:1->2->4, 1->3->4输出:1->1->2->3->4->4来源:力扣(LeetCode)链接:https://leetco...原创 2019-09-23 07:20:09 · 507 阅读 · 0 评论 -
codeforces#586 A.cards B.Multiplication Table(第一次打榜)
第一题Accepted,很直接的想法,有Z就是一个0,有n就是一个1.#include <iostream>#include <string>#include <map>using namespace std;int main(){ int N; string str; cin>>N; cin>...原创 2019-09-21 20:48:36 · 255 阅读 · 0 评论 -
排序算法:选择排序、插入排序、希尔排序、归并排序、快速排序
c++STL里面是有排序接口的,不过还是想学习一下经典的排序算法。我没有使用模板类来实现,而是指定了整形数组。上代码,方便以后看:***.h#pragma once#include <iostream>#include <vector>using namespace std;class MySort{public: MySort(); ~MyS...原创 2019-09-19 21:21:36 · 301 阅读 · 0 评论 -
牛顿迭代法开方
上代码:#include <iostream>class MyAlgo{public: MyAlgo(); ~MyAlgo(); double mi(double x, int y); double kaifang(int m, int n);};double MyAlgo::mi(double x, int y){ while (y > 1)...原创 2019-09-19 17:04:52 · 594 阅读 · 0 评论 -
在C++中用堆来实现最基本的优先队列
许多应用程序都需要处理有序元素,但是不一定要求他们完全有序。很多情况下只需要处理当前最大元素,然后数据集合变化后再继续处理最大元素。在这种情况下,一个合适的数据结构应支持两种关键操作:1删除最大元素2插入元素。优先队列具备这种特质。优先队列可以使元素按照自定义的一个优先级来排序,并非加入顺序来排序,高效实现优先队列具有一定挑战性。《算法》一书中介绍了维护一个二叉堆来实现高效的优先队列插入删除操...原创 2019-07-26 01:15:24 · 699 阅读 · 0 评论 -
按照C++Prinmer顺序梳理了容器模板类和接口特点
C++string类库:<string> 见Primer77 -字符操作<cctype> -容器的统一接口 -string类特有接口C++数组和兼容C代码字符串的接口: -C++11标准库为了契合容器/迭代器的概念,提供begin()end(),来返回数组的首尾指针 -C风格字符串:&...原创 2019-07-12 15:37:04 · 360 阅读 · 0 评论