![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
文章平均质量分 54
Iohboel
欢迎访问最新博客https://lifeilu.github.io/
展开
-
如何打乱100个数呢?
如何将100个数字打乱呢?最直观的想法就是选用两个数组,一个存储原来的顺序存储的数字,记做A,另一个存储打乱后的序列,记做B。每次从原来的数组里面随机抽取一个序号,比如,抽取10,将A[10]里的数字存储到B[0],之后将A[11]~A[99]的数字顺序前移,重复执行上面的步骤,指导最后一个数字存储到B[99]。但是这种算法的不足之处就是每次都要大量的移动数组A中的数字,由此可以想到采用链原创 2016-04-16 21:20:28 · 5036 阅读 · 0 评论 -
如何开平方
/* *功能:开方 *作者:KDF5000 *时间:2013.3.2 */ #include int main() { float a; float x; //x为所求结果 int i=100; //控制循环的次数a printf("请输入要开方的数:"); scanf("%f",&a); x=a/2;原创 2016-04-17 23:28:50 · 519 阅读 · 0 评论 -
leecode Nim Game
You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the原创 2016-04-20 19:52:54 · 321 阅读 · 0 评论 -
leecode Add Digits
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one原创 2016-04-20 20:18:59 · 360 阅读 · 0 评论 -
leecode Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.求二叉树的最大深度,如果根结点为空,返回0,否则返回左右结点的深度的较大值原创 2016-04-20 20:40:17 · 314 阅读 · 0 评论 -
《算法设计与分析》习题解答笔记
题外话:近期准备复习一下算法的知识,顺便刷几道习题,在这边记一下笔记,方便之后查看。~~~~~~~~~~~~~~~~~~~~~~~~~~~~~我是分割线~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~习题1-2 方法头签名 方法签名由方法的名称和它的每一个形参(按从左到右的顺序)的类型和种类(值、引用或输出)组成。需注意的是,方法签名既不包原创 2016-09-19 20:19:58 · 6245 阅读 · 0 评论