自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(69)
  • 资源 (1)
  • 收藏
  • 关注

原创 【Rust】用RefCell避开`&mut XX`导致的借用检查

用RefCell 消除 &mut X

2022-09-09 12:23:50 323 1

原创 【Rust】用libc实现文件拷贝

【Rust】用libc实现文件拷贝

2022-09-06 12:55:28 657

原创 [Rust] 动态分发的特征对象( &dyn Trait / Box<dyn Trait> )

rust 动态分发 特征对象 (&dyn trait / Box)

2022-08-15 11:47:44 633

原创 【Rust】可变引用的独占性

rust的可变引用理解

2022-08-11 10:14:31 206

原创 【C++】尝试实现 `is_constructible`

目前的测试用例都通过了,但可能还有行为和 std::is_constructible 不一致#include <cstdint>#include <type_traits>template<class T>struct is_reference : std::is_same<T,std::remove_reference_t<T> > {};template<class T>inline constexpr bool i

2022-05-10 11:23:59 734

原创 【codewars-20】素数的间距

The prime numbers are not regularly spaced. For example from 2 to 3 the step is 1. From 3 to 5 the step is 2. From 7 to 11 it is 4. Between 2 and 50 we have the following pairs of 2-steps primes:3, 5 - 5, 7, - 11, 13, - 17, 19, - 29, 31, - 41, 43We will

2022-04-02 14:32:53 194 1

原创 【codewars-19】斐波那契的变种问题

Well met with Fibonacci bigger brother, AKA Tribonacci.As the name may already reveal, it works basically like a Fibonacci, but summing the last 3 (instead of 2) numbers of the sequence to generate the next. And, worse part of it, regrettably I won’t get

2022-04-02 14:08:46 193

原创 【codewars-18】弹跳球

A child is playing with a ball on the nth floor of a tall building. The height of this floor, h, is known.He drops the ball out of the window. The ball bounces (for example), to two-thirds of its height (a bounce of 0.66).His mother looks out of a window

2022-04-02 13:14:39 204

原创 【C++】模板元编程 学习笔记

利用模板推导来判断类型是否为整数?首先用一个非特化的模板来标记非数字的情形.template<typename T>struct st_integer{ static const bool value = false ;};下面用各种整数类型来(完全) 特化模板st_integer , 并增加类型字段来记录具体的整数类型:template<>struct st_integer<int> { static const bool value = true

2022-03-29 22:28:26 850

原创 【codewars-17】统计字符的出现次数

The main idea is to count all the occurring characters in a string. If you have a string like aba, then the result should be {‘a’: 2, ‘b’: 1}.What if the string is empty? Then the result should be empty object literal, {}.#include <map>#include &l

2022-03-29 14:43:47 131

原创 【codewars-16】根据大小写的比例转换大小写

In this Kata, you will be given a string that may have mixed uppercase and lowercase letters and your task is to convert that string to either lowercase only or uppercase only based on:make as few changes as possible.if the string contains equal number o

2022-03-29 14:32:17 126

原创 【codewars-15】返回去除了奇数的数组

The solution would work like the following:get_even_numbers({2,4,5,6}) => {2,4,6}朴素的解法#include <vector>#include <numeric>std::vector<int> get_even_numbers(const std::vector<int>& arr) { std::vector<int> re

2022-03-28 21:50:44 403

原创 【codewars-14】选择性转换大写

Given a string, capitalize the letters that occupy even indexes and odd indexes separately, and return as shown below. Index 0 will be considered even.For example, capitalize(“abcdef”) = [‘AbCdEf’, ‘aBcDeF’]. See test cases for more examples.The input wi

2022-03-27 16:16:09 411

原创 【codewars-13】和为奇数还是偶数 ?

Task:Given a list of integers, determine whether the sum of its elements is odd or even.Give your answer as a string matching “odd” or “even”.If the input array is empty consider it as: [0] (array with a zero).Examples:Input: [0]Output: "even"Input

2022-03-27 15:43:13 166

原创 【codewars-12】Parts of a list. 分割list

Write a function partlist that gives all the ways to divide a list (an array) of at least two elements into two non-empty parts.Each two non empty parts will be in a pair (or an array for languages without tuples or a structin C - C: see Examples test Cas

2022-03-27 12:59:13 910

原创 【codewars-11】对多行文本做对称变换 Moves in squared strings (I)

This kata is the first of a sequence of four about “Squared Strings”.You are given a string of n lines, each substring being n characters long: For example:s = "abcd\nefgh\nijkl\nmnop"We will study some transformations of this square of strings.Vertic

2022-03-27 00:34:00 205

原创 【codewars-10】字符串的结尾

Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).Examples:solution('abc', 'bc') // returns truesolution('abc', 'd') // returns false要点用迭代器初始化字符串的方式截取出字符串的尾部要在str长度>e

2022-03-25 21:55:21 274

原创 【C++】模板 备忘

类型退化 std::decaytemplate<class T>struct decay;若T是 类型U的**数组** / 对类型U的**数组的引用**, 则退化后的类型为U*若T为一个函数类型F/对函数的引用, 则退化后的类型为std::add_pointer<F>::type否则, 对其余所有类型, 其退化后的类型为 std::remove_cv<std::remove_reference<T>::type>::type因此粗略来讲, d

2022-03-25 21:28:34 1067

原创 【codewars-9】预测年龄

My grandfather always predicted how old people would get, and right before he passed away he revealed his secret!In honor of my grandfather’s memory we will write a function using his formula!Take a list of ages when each of your great-grandparent died.

2022-03-25 21:27:18 280

原创 【codewars-8】字符串二合一

Take 2 strings s1 and s2 including only letters from ato z. Return a new sorted string, the longest possible, containing distinct letters - each taken only once - coming from s1 or s2.用两个字符串中的字符组成无重复字符且升序排列的字符串Examples:a = "xyaabbbccccdefww"b = "xxxxyy

2022-03-25 11:47:58 139

原创 【codewars-7】打印错误

In a factory a printer prints labels for boxes. For one kind of boxes the printer has to use colors which, for the sake of simplicity, are named with letters from a to m.The colors used by the printer are recorded in a control string. For example a “good”

2022-03-25 10:53:01 243

原创 【codewars-6】检测Isograms字符串 (即无重复字符)

An isogram is a word that has no repeating letters, consecutive or non-consecutive. Implement a function that determines whether a string that contains only letters is an isogram. Assume the empty string is an isogram. Ignore letter case. 忽略大小写的区别Example:

2022-03-25 10:09:01 205

原创 【无标题】

Given an array of digitals numbers, return a new array of lengthnumber containing the last even numbers from the original array (inthe same order). The original array will be not empty and will containat least “number” even numbers.For example:26, -6.

2022-03-24 22:23:13 158

原创 【codewars-4】路上的颠簸

Your car is old, it breaks easily. The shock absorbers are gone andyou think it can handle about 15 more bumps before it dies totally.Unfortunately for you, your drive is very bumpy! Given a stringshowing either flat road ("") or bumps (“n”), work out .

2022-03-24 22:00:37 195

原创 【codewars-3】从字符串形式的数字序列中找出最大和最小值

In this little assignment you are given a string of space separated numbers, and have to return the highest and lowest number.ExampleshighAndLow("1 2 3 4 5"); // return "5 1"highAndLow("1 2 -3 4 5"); // return "5 -3"highAndLow("1 9 3 4 -5"); //

2022-03-24 14:29:24 515

原创 【codewars-2】元音字母的个数

Return the number (count) of vowels in the given string.返回给定字符中元音字母的个数。We will consider a, e, i, o, u as vowels for this Kata (but not y).aeiou作为元音字母。The input string will only consist of lower case letters and/or spaces.输入字符串仅由小写字母和空格组成。*要点要用size_

2022-03-24 11:38:29 132

原创 【codewars-1】字谜检测 Anagram Detection

An anagram is the result of rearranging the letters of a word to produce a new word (see wikipedia). 一个单词能通过字母重排变为另一个.Note: anagrams are case insensitive 大小写不敏感Complete the function to return true if the two arguments given are anagrams of each other; re

2022-03-24 11:17:46 202

原创 【Emacs】利用find命令及ivy-read实现搜索项目文件

要点find [搜索路径] [要跳过搜索的东西] -prune -o [其它筛选条件] [要执行的操作]例 find ./ -path "*/.git" -prune -o -type f,d -name "*.*" -print-path后面要接文件路径/路径的模式串path ... -prune是联合使用的, 作用是跳过这些文件-type f,d 表示结果保留普通文件f和目录d-name 模式串 是对指定文件名进行搜索-print 是对find找到的满足条件的文件 实施的动作: 打印文件

2022-03-19 21:46:23 493

原创 【Emacs】利用grep实现搜索文件内容并打开文件

要点:命令示例: grep -nrs --exclude-dir=".git" --exclude-dir=".vscode" "some-text"-n 行号 -s 不显示错误消息-r 等价于 -d recurse 递归读入当前目录下所有文件-exclude-dir="要排除搜索的目录"-d 后接动作,默认的动作为read。因此当输入为目录时,会将目录当做正常文件读入(read动作) 因此输入为目录时,一般要指定动作: -d recurse(defun my-search-file()

2022-03-19 21:05:20 489

原创 【Linux C实现】删除目录下的ELF文件

**重点: **realpath() 将目录路径转换为绝对路径, 借此将目录路径规范为末尾无"/"glob()检索指定模式的文件. 通过flag为目录路径加上"/", 从而实现和普通文件区分basename() 获取文件名部分,从而实现比较不同形式的同一路径下的文件remove() 删除文件或目录ELF文件的第2-4个字节是"ELF"===#include <linux/limits.h>#include <stdio.h>#include <limits

2022-03-19 20:40:48 347

原创 编译imgui应用

假设您将 imgui 下载到一个名为 $IMGUI_DIR并且包含您的主要功能的文件是 main.cpp,您的编译命令行应如下所示:(\ 只是用来分解命令)g++ main.cpp -o main $IMGUI_DIR/imgui*.cpp $IMGUI_DIR/backends/imgui_impl_glfw.cpp $IMGUI_DIR/backends/imgui_impl_opengl3.cpp -I $IMGUI_DIR -I $IMGUI_DIR/backends -lglfw -lGL

2022-03-19 11:51:46 1402

原创 Emacs文本文件显示异常( 中文utf-8编码 )

emacs 打开包含中文的文本文件后中文显示为8进制但在vim等编辑器中却显示正常用下面的命令可以将编码读取编码硬换成utf-8, 但指标不治本, 下次打开显示依然异常.M-x revert-buffer-with-coding-systemutf-8-unix网上有人遇到类似的问题, 据说是因为文件中包含了空字节,导致文件被识别成了二进制文件. 而emacs的默认行为是 “进行空字节检测” ,这就导致了文本文件被识别成了二进制的数据文件.( file命令显示为data类型, 而不是XX编码的文本

2022-03-19 11:31:37 669

原创 【C++】随手记录

降序排序std::sort( XX.rbegin() , XX.rend() ) ;创建反转字符串std::string(s.rbegin() , s.rend() ) ;字符串转 unsigned long long (uint64)std::stoull(str) -> ullstd::map 可实现简单的switch … case 功能eg: 实现简单的二元加减乘除std::map<char, std::function<int(int , int)> &g

2022-01-31 21:11:44 580

原创 重新配置 vim 时的问题

必要的依赖:已经下载的插件&配置 .vim/ .vimrcvimg++gitcmake makepython3-dev…问题1问题2

2021-12-16 14:30:19 214

原创 【C++】十六进制显示文件内容

#include <iostream>#include <string>#include <iomanip>#include <fstream> #include <cctype>#include <cstdlib>int main(int argc ,char* argv[] ){ if(argc<2){ std::cerr << "usage: " << ...

2021-12-09 08:44:21 1292 1

原创 【C++】函数容器实现

#include <iostream>#include <thread>#include <map>#include <functional>#include <stdlib.h>#include <tuple>#include <type_traits>//// https://github.com/qicosmos/cosmos/blob/master/function_traits.hpp// ht

2021-11-25 11:57:18 689

原创 RTTI 运行时类型识别

安全的类型转换 dynamic_cast<子类*> (父类指针)#include <iostream>//RTTIclass Human{public : Human(){} virtual ~Human(){} //为了使用dynamic_cast将父类指针转换为子类,父类中至少有一个为虚函数,通常是虚析构函数 void func() { std::cout << "parent class!"<<std::e

2021-11-20 17:14:04 186

原创 virtualbox 共享文件夹

2021-11-06 10:26:36 106

原创 数据库02

SQL是关系代数的一种实现方式,它让我们不用考虑数据集的特征来自行编写合适的代码。例子:聚合函数只能出现在select部分中在count中,目的只是为了计算tuple的个数,因此也可以写为:可以使用多个聚合函数:所有登录名包含了 的学生数和学生的平均gpaCOUNT SUM AVG 都支持去重 DISTINCT在这个例子用其实不太恰当,因为没有不同的 学生会有相同的登录名。GROUP BYselect中出现的只能是聚合函数值,或者是在group by中出现的字段group by

2021-11-03 21:56:01 45

原创 linux下understand5.1安装

linux understand5.1

2021-10-30 23:01:34 2978 6

《算法设计》Kleinberg 练习 答案

《算法设计》Kleinberg 练习 答案

2022-03-31

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除