分类 计算机技术笔记 下的文章

python中的p=re.compile(r"") p.match("...")只会从头匹配到尾,一般用于split之后的token的匹配,因此一般使用re.findall("..."),或直接替换用re.sub()给定类似[!abc](sfsdfsdf)abc类型的字符串,如何把它替换成$abc?s=re.sub(r"\...

展开阅读

?表示单个字符;*(star)表示任意数量的字符;**(global star)表示递归地匹配任意数量的字符,包括/;[aeiou]和正则表达式意义相同,但是匹配失败时会escape变回原意;[!aeiou]表示除了aeiou;{aeiou}匹配失败时不会变回原意,并且可以嵌套其他通配符,{a..z}匹配a到z通配符是先解释,再执行。不匹配时,会原样输出。只适用于单层路径(除了global ...

展开阅读

初始化动态二维矩阵#include<stdio.h> #include<stdlib.h> int** matrix(int height,int width,int initial) { int **a=malloc(sizeof *a * height); printf("Initializing matrix of size %d X ...

展开阅读

录制宏qq x x <Esc> q执行宏@q分屏:sp filename :vsp filename <Ctrl + w> v <Ctrl + w> s <Ctrl + w> h <Ctrl + w> l <Ctrl + w> j <Ctrl + w> k跳转到历史编辑位置<Ctrl + o> &...

展开阅读

import numpy as np import cv2 def zmMinFilterGray(src, r=7): '''最小值滤波,r是滤波器半径''' return cv2.erode(src, np.ones((2*r+1, 2*r+1))) def guidedfilter(I, p, r, eps): '''引...

展开阅读

#include<opencv2/opencv.hpp> #include<iostream> #include<iomanip> #include<string> #include<vector> #include<ctime> #include<algorithm> using namespace std...

展开阅读

工具1:在MinGW官网上根据教程下载mingw-get,在MinGW Installation Manager中选中mingw-developer-toolkit-bin,mingw32-base-bin,和mingw32-gcc-g++-bin,并安装到一个没有中文或者空格的目录下工具2:下载git for windows并安装到一个没有中文或者空格的目录下在Makefile文件下打开G...

展开阅读

设有n 种不同面值的硬币,每个硬币的面值存于数组$T[1:n]$中。现在用这些硬币来找钱。各种硬币使用的个数不限。设计一个动态规划算法以计算找出钱m 时,所用的硬币的最小个数C。def change_money(T,m): T.sort() # 保证面额单调递增 n=len(T) C=[[0]*(m+1) for...

展开阅读

以下代码使用了半正矢公式:$\text{haversine}(\varphi_1,\theta_1,\varphi_2,\theta_2)=2R\arctan \sqrt\frac{a}{1-a}, $ 其中 $a=\sin^2\frac{\Delta\varphi}{2} +\cos\varphi_1\cos\varphi_2\sin^2\frac{\Delta \theta}{2}, \...

展开阅读

1. 使用Impredicative Polymorphism(不推荐)使用类型Robot来模拟class Robot,使用State来模拟Robot class的属性值,使用类型Robot -> a来模拟输出类型为a的getter方法,使用Robot->a->Robot或(Robot, Robot )->a->(Robot, Robot)类型的函数模拟sett...

展开阅读