- 博客(42)
- 资源 (2)
- 收藏
- 关注
原创 Int31n()源码解析 ---- math/rand/rand.go
Int31n 用于返回一个类型为 int32 的伪随机非负整数, 其值属于左闭右开区间 [0, n), 其中 n 即调用该函数时传入的参数.在学习该段代码前, 先看一段 C 语言代码: 类似于Int31n(), 这段代码是随机获取一个 [0, 31768) 范围内的整数, 然后循环20万次, 比较前1000个数和后1000个数出现的次数, 理论上期望两者次数应当是 1:1 的比例, 然而实际上前者比后者多出了一倍, 为什么会这样呢? 来看一下 rand() 函数的说明
2022-06-14 22:11:05
801
原创 批处理之批量修改文件扩展名
rem 批量修改文件扩展名rem 在这里设置所有变量rem tp: 目标文件夹路径(无论路径中有没有空格, 均不需要加双引号), 为空表示当前文件夹rem sub: 是否包含子目录, 为/r表示包含, 为空表示不包含rem suffix: 目标扩展名, 不可为空rem new_suffix: 新的扩展名, 不可为空set tp=D:\test\change suffixset sub=/rset suffix=batset new_suffix=txt@echo offse.
2022-05-28 20:09:49
971
原创 Visual Studio 2022 Preview 使用 C++20 Module
作为C++20的一大特性,据说Module能够大大加快项目的编译速度,最近正好看到微软推出了Visual Studio 2022 预览版,随附了面向 C++20 的最新工具链,赶紧拿来体验一下。 体验项目很简单,就两个小文件: 1. hello.ixxexport module mo.hello.cpp;export auto hello(){ return "hello cpp module";} 2. main.cpp...
2021-09-14 08:34:44
3959
原创 用python查询生成国内法定节假日安排
最近对于未成年人玩网游的防沉迷新政又整的沸沸扬扬的,不过作为伪游戏行业从业人员,新政出来,也是不得不跟进的,于是出需求,改代码,一番折腾下来,终于和小学生说拜拜了,呵呵苦笑......功能实现之余,想想这节假日的日子要么是产品整理一下给出来,要么去调别人的接口查,能不能自己去实现一份权威的数据呢,天底下还有python爬不了的数据吗!!!说爬咱就爬,要说权威数据,那肯定是国务院发的新闻最权威,于是乎,找请求,分析结果,终于整理出一份初始数据,不过要想真正可用,还需要分析一下那些假期安排变化的...
2021-09-04 17:15:28
1583
1
原创 redigo遇到protobuf枚举
背景redis中存储着一个hash类型的键:键名:redis:test:hash字段:0值:0代码中操作redis的函数定义为Do(cmd string, args ...interface{}) (reply interface{}, err error) {// TODO}proto文件中有如下定义enum RoomTag{ matchType = 0;}看一下下面的代码// rep预期类型是[]uint8, 转换成string是"0",实
2021-08-13 13:08:18
314
原创 714. 买卖股票的最佳时机含手续费
题目我的方法思路 作为算法小白,官方里的题解什么动态规划,贪心算法,我还真说不上来,只能硬想...... 把开始设为买入点,然后向后找第一个潜在的卖出点(只要收入超过了手续费就是潜在的卖出点),在这个过程中,如果有更低的价格,则这个价格就更新为此次交易的买入点,如果最终找不到卖出点,则不交易,找到了,则可以进行交易,但不一定从这个点卖出,需要则从这个点开始,找下一个买入点(价格下跌超过手续费,就成为买入点),在这个过程中,如果发现更高价格,则把更高价格更新为卖出点,直到找到下...
2021-02-27 15:15:35
107
原创 290. 单词规律
题目给定一种规律 pattern和一个字符串str,判断 str 是否遵循相同的规律。这里的遵循指完全匹配,例如,pattern里的每个字母和字符串str中的每个非空单词之间存在着双向连接的对应规律。示例1:输入: pattern = "abba", str = "dog cat cat dog"输出: true示例 2:输入:pattern = "abba", str = "dog cat cat fish"输出: false示例 3:输入: pattern = ...
2020-12-16 11:30:48
156
原创 49. 字母异位词分组
题目 给定一个字符串数组,将字母异位词组合在一起。字母异位词指字母相同,但排列不同的字符串。示例: 输入: ["eat", "tea", "tan", "ate", "nat", "bat"] 输出: [ ["ate","eat","tea"], ["nat","tan"], ["bat"] ]说明:所有输入均为小写字母。不考虑答案输出的顺序。我的方...
2020-12-15 07:55:40
119
原创 102. 二叉树的层序遍历
目录题目我的方法思路代码题目 给你一个二叉树,请你返回其按 层序遍历 得到的节点值。 (即逐层地,从左到右访问所有节点)。示例:我的方法思路 递归大法好!!!就是在递归时,要传递当前是第几层。 代码/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * ...
2020-05-15 18:27:09
176
原创 136. 只出现一次的数字
目录题目我的方法思路代码题目 给定一个非空整数数组,除了某个元素只出现一次以外,其余每个元素均出现两次。找出那个只出现了一次的元素。说明:你的算法应该具有线性时间复杂度。 你可以不使用额外空间来实现吗?我的方法思路 题目要求线性时间复杂度,说明一次遍历就应该能够找到这个元素了。题目中明确表明除了这个单一元素外,其它元素均出现两次,那么如果其它元素两两抵消,那么最终剩下的元素不就是这个单一元素了嘛!怎样才能让相同的元素两两抵消呢?位运算异或操作-...
2020-05-15 16:35:28
165
原创 数字以任意进制转换成字符串----itoa的实现
这几天需要把一个int型整数转换成指定进制的字符串,在windows下通过itoa实现了这个需求,然后发现在linux下没有这个函数,然后网上都说可以通过sprintf等来实现转换,但是还是不能实现itoa的任意进制转换功能,想看一下itoa的源代码吧,也搜不到,只好参考别人的写法,自己实现了一下这个函数......void itos_upper(int iValue, string &a...
2018-05-22 19:04:49
744
原创 USACO----Combination Lock
Farmer John's cows keep escaping from his farm and causing mischief. To try and prevent them from leaving, he purchases a fancy combination lock to keep his cows from opening the pasture gate.Knowing ...
2018-04-09 21:03:00
285
原创 USACO----Barn Repair
It was a dark and stormy night that ripped the roof and gates off the stalls that hold Farmer John's cows. Happily, many of the cows were on vacation, so the barn was not completely full.The cows spen...
2018-03-19 17:33:14
297
原创 USACO----Mixing Milk
The Merry Milk Makers company buys milk from farmers, packages it into attractive 1- and 2-Unit bottles, and then sells that milk to grocery stores so we can each start our day with delicious cereal a...
2018-03-19 16:48:53
291
原创 USACO----Palindromic Squares
Palindromes are numbers that read the same forwards as backwards. The number 12321 is a typical palindrome.Given a number base B (2 <= B <= 20 base 10), print all the integers N (1 <= N <=...
2018-03-19 16:46:41
258
原创 USACO----Name That Number
Among the large Wisconsin cattle ranchers, it is customary to brand cows with serial numbers to please the Accounting Department. The cow hands don't appreciate the advantage of this filing system, th...
2018-03-19 16:45:06
256
原创 USACO----Transformations
A square pattern of size N x N (1 <= N <= 10) black and white square tiles is transformed into another square pattern. Write a program that will recognize the minimum transformation that has bee...
2018-03-19 16:43:24
239
原创 USACO----Milking Cows
Three farmers rise at 5 am each morning and head for the barn to milk three cows. The first farmer begins milking his cow at time 300 (measured in seconds after 5 am) and ends at time 1000. The second...
2018-03-19 16:41:38
667
原创 USACO----Friday the Thirteenth
Is Friday the 13th really an unusual event?That is, does the 13th of the month land on a Friday less often than on any other day of the week? To answer this question, write a program that will compute...
2018-03-19 16:39:42
244
原创 USACO----Greedy Gift Givers
A group of NP (2 ≤ NP ≤ 10) uniquely named friends has decided to exchange gifts of money. Each of these friends might or might not give some money to some or all of the other friends (although some m...
2018-03-19 16:38:12
348
原创 USACO----Your Ride Is Here
It is a well-known fact that behind every good comet is a UFO. These UFOs often come to collect loyal supporters from here on Earth. Unfortunately, they only have room to pick up one group of follower...
2018-03-19 16:31:49
201
原创 查看支持球队一周比赛安排的python脚本
# -*- coding: utf-8 -*-import urllib.requestimport randomimport reimport datetimefrom bs4 import BeautifulSoupurl = "http://www.dongqiudi.com/match/fetch_new?tab=null&date=%s&scroll_t...
2018-03-13 14:31:49
240
转载 由localtime引发的函数可重入问题
原文地址: http://blog.youkuaiyun.com/cuishumao/article/details/10162603优快云为什么没有转载功能呢???一、先看一个例子[html] view plain copy#includetime.h> #include windows.h> in
2017-12-07 10:34:57
382
原创 批处理查找并复制文件到指定文件夹
如何通过批处理,在一个目录及其子目录中查找指定列表中的所有文件,并把这些文件复制到指定的文件夹中呢?下面这个批处理可堪一用:
2017-05-07 00:07:06
23030
19
转载 fstream类读取UTF-8、Unicode和ANSI文本文档乱码问题的解决方案
原文链接:https://my.oschina.net/duluo180/blog/174571、解决UTF-8类型的文本文档中文乱码读取(思路:将UTF-8转成Unicode然后再转ANSI)#include #include #include // #include #include //changeTextFromUtf8ToAnsi读取UTF-8格式的文件并将之保
2016-12-19 16:40:47
10497
原创 查看喜爱球队一周比赛安排
平时上班比较忙,经常错过支持的球队的比赛,所以能够知道支持的球队本周都有哪些比赛将会是一个不错的选择,于是自己动手实现了这个想法。初学Python,练习的缘故,部分功能使用python实现。总体思想就是从指定网站下载下比赛信息,然后分析之。 C++部分,主要实现文件的下载:#include #include #include #include #include usin
2016-03-13 00:09:34
840
原创 C实现两个大数相加
#include #include int main(){ char snum1[1024], snum2[1024], sop1[1024]="0", sop2[1024]; int len, len1, len2, opsign = 0; printf( "输入两个操作数:\n" ); scanf( "%s\n%s", snum1, snum2 );
2016-03-07 12:28:30
956
原创 使用Python发送带附件的邮件
做运维值班时,每天早上都要通过邮箱发送日报,最近开始学习Python,这下可以让电脑自己去发邮件了 初学Python,相关代码可能不够完善,使用的是python 3.5版本。 实际遇到最大的问题就是使用网页版邮箱时,附件是中文时会导致乱码的问题,网上查了查有好多不同的版本,经过验证总结,总算在我这个环境上(Win10+IE11)通过了。
2016-01-19 13:41:41
889
原创 能够把自动问答机制应用到运维中吗?
在游戏运维一线做了很长一段时间了,每天上班都要应付不同部门,不同的人提的各种需求,杂乱而又繁琐,有时候整天都会消耗在这些零碎的事情上,让人疲于应付。不过在做过一段时间后,慢慢发现,需要做的事情好多都是相似的,那么可不可以让计算机去自动处理这些琐碎的需求,我们只负责监督呢?甚至让需求人员直接去和计算机进行交互,就像一些网站上的在线客服一样,然后计算机就能够解决需求人员的大部分需要呢?基于此,我有了下
2015-03-04 14:33:22
879
转载 Visual C++ .NET 中 System::String^ 和 char * 互转
原文链接:http://blog.youkuaiyun.com/qq506124204/article/details/8969490使用 Visual C++ .NET 中的托管扩展从 System::String^ 转换为 char* 的若干方法。 方法 1StringToHGlobalAnsi 将托管 String 对象的内容复制到本机堆,然后动态地将它转换为
2014-12-01 06:10:13
780
转载 C# checklistbox控件用法总结(怎样得到多选的值,以及动态加载数据)
原文链接:http://blog.sina.com.cn/s/blog_4cf58c9c010106mx.html一般认为:foreach (object obj in checkedListBox1.SelectedItems)即可遍历选中的值。其实这里遍历的只是高亮的值并不是打勾的值。遍历打勾的值要用下面的代码:for (int i = 0; i checked
2014-12-01 06:08:24
992
原创 DOS下比较两个文件的大小
首先建立一个批处理文件,命名为comparesize.bat.@echo offrem 比较两个文件的大小,返回较大文件的编号,相同返回0.set file1=%1set file2=%2dir /-c %file1%>comparetemp1.txtdir /-c %file2%>comparetemp2.txtfindstr /c:"1 个文件" comparetemp1.tx
2014-10-16 14:25:58
3498
翻译 如何使用VS2008 C++/CLI 来自动化操作Excel
Use Visual Studio 2008 C++/CLI to Automate Excel
2014-09-30 13:37:32
2868
原创 Linux程序设计——The Standard I/O Library
fopenHere’s the syntax:#include FILE *fopen(const char *filename, const char *mode);
2014-06-30 15:48:33
711
原创 用C语言实现一个日历显示
#include #include #define SIGN_WEEK 6#define SIGN_YEAR 2000int month_day[14]={31,31,0,31,30,31,30,31,31,30,31,30,31,31};char month_name[12][10]={"January","February","March","Apirl","May
2014-06-07 19:53:48
2029
原创 C语言检查本机公网IP并发送邮件
#include #include #include #include #include #include #define N 500using namespace std;#pragma comment(lib, "ws2_32.lib")#pragma comment(lib,"urlmon.lib")struct Base64Date6{ unsigned
2014-05-19 05:08:18
2559
检查公网IP并发送邮件
2014-05-19
励志桌面小工具
2013-05-17
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人