temp

python的base64编码代码实现

*爱你&永不变心* 提交于 2020-01-20 01:22:33
python的base64编码代码实现(学习记录) base64_list = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'] def encode_ascii(string: str) -> str: temp = '' base = '' # 把原始字符串转换为二进制,用bin转换后去掉开头的0b,首位补0补齐8位 for i in string: temp += '{:08}'.format(int(str(bin(ord(i))).replace('0b', ''))) # 6位一组截取,最后一组不足6位的后面补0,获取base_list中对应的字符 for j in range(0,

二叉平衡树

别等时光非礼了梦想. 提交于 2020-01-19 22:53:35
定义 是一个特殊的 二叉查找树 任何结点的两个子树的高度差小于等于1 前5个函数为后面的功能做铺垫,一般的树都有这些函数 1. 结点 public class Node{ int height; //树高 int value; //存值 Node left; Node right; public Node(int value, Node left, Node right) { this.value = value; this.left = left; this.right = right; this.height = 0; //默认树高为0 } } 2. 树高 //树高 public int height(){ return height(root); } private int height(Node node){ if(node != null){ return node.height; } return 0; //默认为0 } 3. 比大小 //比大小 private int max(int a,int b){ return a>b ? a : b; } 4. 找最值及其结点 //最值 public int min(){ Node node = minTree(root); if(node != null){ return node.value; } return 0; }

2020-01-19

為{幸葍}努か 提交于 2020-01-19 19:52:47
C语言实现简单功能的12306火车售票系统【附源码】 程序设计要求用C语言写一个简单的火车售票系统,主要实现的功能为: 录入班次信息 浏览班次信息 按班次号查询 按终点站查询 按余票数量排序保存 售票 退票 更新班次信息 退出系统 所有的班次信息保存在number.dat文件中,排序过后的保存在sort.dat中(.dat是一种二进制文件)。 在编写的过程中我觉得在判断火车的状态比较值得深究。这里假设火车主要有四种状态: 1.未发车 2.已发车 3.停止检票 4.停止退票 在程序中,思路是将代表发车时间的字符串转化为整型,再和系统现在的时间进行大小比较,主要采用if判断各种情况。其中atime代表的是发车时间的整型数,btime代表的是系统时间的整型数,具体实现如下: if(atime<=btime) //已经发车 return 1; if(((atime-btime<=30)&&(atime-btime>5)&&(atime/100 btime/100))||(((atime%100+(60-btime%100))<=30)&&(atime%100+(60-btime%100))>5&&(atime/100-btime/100 1))) //距发车半小时以内,停止退票,%表示取余 return 2; if(((atime-btime<=5)&&(atime/100 btime

从尾到头打印链表

只愿长相守 提交于 2020-01-19 17:35:26
从尾到头打印链表 题目描述 输入一个链表,按链表 从尾到头 的顺序返回一个ArrayList 看到这道题,很多人的第一反应是从头到尾的输出将会比较简单,于是我们很自然的想把链表中连接节点的指针反转过来,改变链表的方向,然后就可以从头到尾输出了。但该方法会改变原有链表的结构,是否允许在打印链表的时候修改链表的结构?这取决于面试官的要求。 思路分析 思路一:使用栈 遍历的顺序时从头到尾,可输出的顺序确是从尾到头。* 也就是说: 第一个遍历的节点最后一个输出;而最后一个遍历的节点第一个输出 ; ​ 这就是典型的 先进后出 。 ​ 我们可以使用 栈 这种顺序; ​ 每经过一个节点的时候,把该节点放入栈中。 ​ 当遍历完整个链表后,再从 栈顶开始逐个输出节点的值 ,此时输出节点的顺序已经反转股哟开了* /** * @param listNode * @return * 使用栈 :数据结构 * 遍历的顺序时从头到尾,可输出的顺序确是从尾到头。 * 也就是说:第一个遍历的节点最后一个输出;而最后一个遍历的节点第一个输出; * 这就是典型的先进后出。我们可以使用 栈 这种顺序 * 每经过一个节点的时候,把该节点放入栈中。当遍历完整个链表后,再从栈顶开始逐个输出节点的值,此时输出节点的顺序已经反转股哟开了 * */ public static ArrayList < Integer >

leetcode64.最小路径和

ぐ巨炮叔叔 提交于 2020-01-19 02:25:42
给定一个包含非负整数的 m x n 网格,请找出一条从左上角到右下角的路径,使得路径上的数字总和为最小。 说明:每次只能向下或者向右移动一步。 示例: 输入 : [ [ 1 , 3 , 1 ] , [ 1 , 5 , 1 ] , [ 4 , 2 , 1 ] ] 输出 : 7 解释 : 因为路径 1 → 3 → 1 → 1 → 1 的总和最小。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/minimum-path-sum 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 完整代码 采用回溯的思想结果运行超时,一共61个测试用例,只通过了60个. 尽管想得到的剪枝都剪了,实在想不到如何来优化了。 class Solution { public : int minPathSum ( vector < vector < int >> & grid ) { if ( grid . size ( ) == 0 ) return 0 ; int res = INT_MAX ; path ( grid , res , 0 , 0 , 0 ) ; return res ; } private : void path ( vector < vector < int >> & grid , int & res , int

2020-01-18

断了今生、忘了曾经 提交于 2020-01-19 00:11:46
function prototype函数原型 子函数放主函数上面 按键检测代码用计数方式 对temp定义要写在循环内部(可能是每次循环后temp都不一样了要重新定义一下) 按键的三种状态也写在if(k1==0)内部,不然无法控制按键 temp1=0xef; temp2=0xf7; for(k=0;k<4;k++) { temp=temp1&temp2; led=temp; delay(50000); temp1= crol (temp1,1); temp2= cror (temp2,1); } 7. 终于搞了个完整的程序 感谢百度 我太菜了晚饭多吃点补补脑子 来源: CSDN 作者: 取个昵称好困难啊 链接: https://blog.csdn.net/weixin_44814742/article/details/104031197

zabbix监控-部署(一)

强颜欢笑 提交于 2020-01-18 18:37:12
zabbix之自动化监控-部署篇(一) 标签(空格分隔): linux 笔者Q:972581034 交流群:605799367。有任何疑问可与笔者或加群交流 浅谈监控 监控命令 查看硬件的温度/风扇转速,电脑有鲁大师,服务器有ipmitool。使用ipmitool实现对服务器的命令行远程管理 yum -y install OpenIPMI ipmitool #->IPMI在物理机可以成功,虚拟机不行 [root@KVM ~]# ipmitool sdr type Temperature Temp | 01h | ns | 3.1 | Disabled Temp | 02h | ns | 3.2 | Disabled Temp | 05h | ns | 10.1 | Disabled Temp | 06h | ns | 10.2 | Disabled Ambient Temp | 0Eh | ok | 7.1 | 22 degrees C Planar Temp | 0Fh | ns | 7.1 | Disabled IOH THERMTRIP | 5Dh | ns | 7.1 | Disabled CPU Temp Interf | 76h | ns | 7.1 | Disabled Temp | 0Ah | ns | 8.1 | Disabled Temp | 0Bh | ns

【数据结构22】希尔排序

梦想与她 提交于 2020-01-18 08:17:38
1. 希尔排序介绍 2. 希尔排序思路 3. 代码实现 3.1 交换法 希尔排序推导过程: public class ShellSort { public static void main ( String [ ] args ) { int [ ] arr = { 8 , 9 , 1 , 7 , 2 , 3 , 5 , 4 , 6 , 0 } ; System . out . println ( "排序前:" + Arrays . toString ( arr ) ) ; shellSort ( arr ) ; } public static void shellSort ( int [ ] arr ) { int temp = 0 ; //第一轮排序:将10个数据分成5组 for ( int i = 5 ; i < arr . length ; i ++ ) { //如果当前元素大于步长后面的那个元素,说明交换 for ( int j = i - 5 ; j >= 0 ; j -= 5 ) { if ( arr [ j ] > arr [ j + 5 ] ) { temp = arr [ j ] ; arr [ j ] = arr [ j + 5 ] ; arr [ j + 5 ] = temp ; } } } System . out . println ( "第1轮:" )

Tomcat集群搭建部署(二)

允我心安 提交于 2020-01-18 00:06:14
# 创建目录 mkdir /usr/local/tomcat_all # 解压Tomcat包 tar zxf apache-tomcat-7.0.47.tar.gz # 递归拷贝Tomcat下文件至指定路径 cp -r apache-tomcat-7.0.47/* /usr/local/tomcat_all/ # 进入路径 cd /usr/local/tomcat_all/ # 创建Tomcat1和2两个目录 mkdir -p /usr/local/tomcats/tomcat1 mkdir -p /usr/local/tomcats/tomcat2 # 拷贝Tomcat安装目录下的conf目录分别到两个实例的目录中 cp -r /usr/local/tomcat_all/conf/ /usr/local/tomcats/tomcat1/ cp -r /usr/local/tomcat_all/conf/ /usr/local/tomcats/tomcat2/ # 修改第一个Tomcat的配置文件,同样分别修改三个端口 vim /usr/local/tomcats/tomcat1/conf/server.xml # 修改第二个Tomcat的配置文件,同样分别修改三个端口 cd .. cd .. /tomcat2/conf/ vim server.xml #

BFS的记录

不想你离开。 提交于 2020-01-17 23:23:47
对于BFS的一些疑惑 首先,BFS是从中心向四个方向蔓延过去,之前首先看到的是leetcode推箱子 添加链接描述 的这段定义结构体的最优队列的BFS class Solution { public: struct Node{ Node(int x0,int y0,int bx0,int by0){ x=x0;y=y0; bx=bx0;by=by0; } int x,y; int bx,by; friend bool operator < (const Node a,const Node b){ if(a.x!=b.x) return a.x<b.x; if(a.y!=b.y) return a.y<b.y; if(a.bx!=b.bx) return a.bx<b.bx; return a.by<b.by; } }; int cx[4]={0,1,0,-1}; int cy[4]={1,0,-1,0}; map<Node,int>dis; map<Node,bool>inQue; int minPushBox(vector<vector<char>>& grid) { int n=grid.size(),m=grid[0].size(); int sx,sy,ex,ey,bx,by; for(int i=0;i<n;i++) for(int j=0;j<m;j++){ if