- 博客(46)
- 资源 (9)
- 收藏
- 关注
原创 codeblocks 调试失败注意事项
如何调试请看这篇博客:https://www.cnblogs.com/esCharacter/p/7927696.html我设置断点后,调试时直接跳过断点结束运行。原因是项目路径中含有中文。程路径不能有中文,也不能有空格。所以一定要全英文路径,而且空格要用下划线代替。...
2018-09-30 11:45:38 1610
原创 1068 Find More Coins (30 分)
1068 Find More Coins (30 分)Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds o...
2018-09-29 22:13:04 541
原创 PAT甲级 1067 Sort with Swap(0, i) (25 分)贪心算法
1067 Sort with Swap(0, i) (25 分)Given any permutation of the numbers {0, 1, 2,..., N−1}, it is easy to sort them in increasing order. But what if Swap(0, *) is the ONLY operation that is allowed to ...
2018-09-28 16:33:25 291
原创 PAT甲级 1066 Root of AVL Tree (25 分)AVL树
1066 Root of AVL Tree (25 分)An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by...
2018-09-27 22:28:53 233
原创 PAT甲级 1065 A+B and C (64bit) (20 分)
1065 A+B and C (64bit) (20 分)Given three integers A, B and C in [−263,263], you are supposed to tell whether A+B>C.Input Specification:The first line of the input gives the positive num...
2018-09-27 22:23:50 233 1
原创 已知完全二叉树的前序遍历数组,求层次遍历与后序遍历
注意:此种方法仅适用于完全二叉树或满二叉树!!!此种方法仅适用于完全二叉树或满二叉树!!!此种方法仅适用于完全二叉树或满二叉树!!!先根据前序数组得到树的各个结点下标对应的值。例如对于i结点,左子结点是2i,右子结点是2i+1.层次遍历数组:由上已求得tree后序遍历数组:通过后序遍历可得到pos程序代码如下:#include<iostream>using na...
2018-09-27 20:28:44 2902 1
原创 迅雷2019 [编程题] 2的N次方 (大数乘法)
原题链接:https://www.nowcoder.com/test/12398771/summary[编程题] 2的N次方时间限制:1秒空间限制:131072K对于一个整数N(512 <= N <= 1024),计算2的N次方并在屏幕显示十进制结果。 输入描述:输入一个整数N(512 <= N <= 1024)输出描述:2的N次方的十...
2018-09-27 16:53:05 1186
原创 构建带父结点的二叉树,并输出所有结点到根结点的路径
在构建好二叉树后,需要通过一次遍历来给每个结点的parent赋值,关键代码如下:void triBtee(BTNode *p,BTNode *q)//给各个结点的parent赋值{ if(p == nullptr) return; p->parent = q; q = p; triBtee(p->left,q); triBtee(p->right,q);}...
2018-09-27 16:09:45 1634
原创 PAT甲级 1064 Complete Binary Search Tree (30 分)完全二叉树、BST
1064 Complete Binary Search Tree (30 分)A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with key...
2018-09-23 22:18:18 191
原创 PAT甲级 1063 Set Similarity (25 分)Set集合
1063 Set Similarity (25 分)Given two sets of integers, the similarity of the sets is defined to be Nc/Nt×100%, where Nc is the number of distinct common numbers shared by the two sets, and N...
2018-09-23 22:13:35 181
原创 PAT甲级 1062 Talent and Virtue (25 分)排序
1062 Talent and Virtue (25 分)About 900 years ago, a Chinese philosopher Sima Guang wrote a history book in which he talked about people's talent and virtue. According to his theory, a man being outs...
2018-09-23 22:07:56 136
原创 PAT甲级 1060 Are They Equal (25 分)科学计算表示
1060 Are They Equal (25 分)If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved as 0.123×105 with simple chopping. No...
2018-09-23 22:03:58 207
原创 PAT甲级 1059 Prime Factors (25 分)素数表的建立
1059 Prime Factors (25 分)Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format N = p1k1×p2k2×⋯×pmkm.Input Specifi...
2018-09-21 22:25:44 522
转载 掌握树状数组~彻底入门
原文链接:https://www.cnblogs.com/acgoto/p/8583952.html先贴一下树状数组的模板代码: 1 int lowbit(int i) 2 { 3 return i & -i;//或者是return i-(i&(i-1));表示求数组下标二进制的非0最低位所表示的值 4 } 5 void update(int i,in...
2018-09-20 11:29:26 145
原创 1057 Stack (30 分)树状数组
1057 Stack (30 分)Stack is one of the most fundamental data structures, which is based on the principle of Last In First Out (LIFO). The basic operations include Push (inserting an element onto the t...
2018-09-19 22:04:33 253
原创 PAT甲级 1061 Dating (20 分)字符串处理(易粗心)
1061 Dating (20 分)Sherlock Holmes received a note with some strange strings: Let's date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm. It took him only a minute to figure out that t...
2018-09-18 16:31:40 662
原创 KMP 算法
之前找了几篇KMP算法详解,还有视频。都不是很能搞明白代码怎么实现。然后看了胡凡的算法笔记,感觉非常的简单易懂,一遍看下去直接明白了~~在书中的445页。想清楚了解的可以下载电子档看相关内容~~~因为内容解析文字过多,这里只贴代码。KMP算法实现代码如下:#include<iostream>using namespace std;int Next[100] = {0};...
2018-09-16 11:56:57 99
原创 PAT甲级 1058 A+B in Hogwarts (20 分)水题
1058 A+B in Hogwarts (20 分)If you are a fan of Harry Potter, you would know the world of magic has its own currency system -- as Hagrid explained it to Harry, "Seventeen silver Sickles to a Galleon ...
2018-09-15 21:23:47 207
原创 PAT甲级 1056 Mice and Rice (25 分)队列
1056 Mice and Rice (25 分)Mice and Rice is the name of a programming contest in which each programmer must write a piece of code to control the movements of a mouse in a given map. The goal of each m...
2018-09-15 20:58:48 229
原创 LeetCode 8. 字符串转整数 (atoi)
8. 字符串转整数 (atoi) 实现 atoi,将字符串转为整数。在找到第一个非空字符之前,需要移除掉字符串中的空格字符。如果第一个非空字符是正号或负号,选取该符号,并将其与后面尽可能多的连续的数字组合起来,这部分字符即为整数的值。如果第一个非空字符是数字,则直接将其与之后连续的数字字符组合起来,形成整数。字符串可以在形成整数的字符后面包括多余的字符,这些字符可以被忽略,它们对于...
2018-09-15 16:12:07 143
原创 PAT甲级 1055 The World's Richest (25 分)排序
1055 The World's Richest (25 分)Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world's wealthiest people. Now you are supposed to simulate this job, ...
2018-09-15 15:59:20 144
原创 二叉树的遍历(基于栈的非递归方式实现)
原文链接:二叉树的遍历(基于栈的非递归方式实现)二叉树的遍历(基于栈的非递归方式实现)注意:pop的顺序就是对应遍历的打印顺序。在写二叉树的时候如果用递归实现二叉树的遍历很简单,但是用非递归来实现二叉树的遍历就不那么简单了需要一些技巧。那为什么还要非递归实现呢?个人理解:如果树的高度很大,超过了允许递归的次数,那么就会出错,比如我记得python只允许递归100次(不知道记错没)...
2018-09-14 15:56:09 596
原创 PAT甲级 1054 The Dominant Color (20 分)map,水题
1054 The Dominant Color (20 分)Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of information for each pixel. In an image, the color with the largest p...
2018-09-13 15:52:24 151
原创 PAT甲级 1053. Path of Equal Weight DFS,树的遍历记录路径
1053 Path of Equal Weight (30 分)Given a non-empty tree with root R, and with weight Wi assigned to each tree node Ti. The weight of a path from R to L is defined to be the sum of the weights o...
2018-09-13 15:39:29 178
原创 PAT甲级 1052 Linked List Sorting (25 分)排序
1052 Linked List Sorting (25 分)A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key and a Next pointe...
2018-09-12 16:25:02 206
转载 C++Primer第五版——习题答案+详解(完整版)
原文链接:https://blog.csdn.net/misayaaaaa/article/details/53786215C++Primer第五版——习题答案详解 新手入门必看的书。知识是一个系统化并且相互关联的体系,零散的东西每天收获如果不形成自己的体系的话,那将是毫无意义的,所以我觉得有必要将这本书先啃一遍,消化其中的关键有用的东西,了解相关但是目前不那么重要的东西。...
2018-09-12 10:54:09 116270 17
转载 二叉树-最近的公共祖先
原文链接:https://www.jianshu.com/p/7a2d982c247b已知二叉树,求二叉树中给定的两个节点的最近公共祖先。 最近公共祖先: 两节点v与w的最近公共祖先u,满足在树上最低(离根最 远),且v,w两个节点都是u的子孙。LeetCode 236. Lowest Common Ancestor of a Binary Tree思考与分析1.两个节点的公共祖先一定...
2018-09-10 21:33:47 1510
原创 PAT 2018秋季考试甲级 1148-1151
1148 Werewolf - Simple Version(20 分)Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose that in a game,player #1 said: "Play...
2018-09-10 21:31:10 547
原创 PAT甲级 1051 Pop Sequence(25 分)栈模拟
1051 Pop Sequence(25 分)Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, ..., N and pop randomly. You are supposed to tell if a given sequence of numbers is a p...
2018-09-07 21:02:08 221
原创 1050. String Subtraction (20)-PAT甲级真题(哈希)
1050. String Subtraction (20)-PAT甲级真题(哈希)Given two strings S1 and S2, S = S1 – S2 is defined to be the remaining string after taking all the characters in S2 from S1. Your task is simply to calculat...
2018-09-07 18:28:26 102
原创 1049 Counting Ones(30 分)
1049 Counting Ones(30 分)The task is simple: given any positive integer N, you are supposed to count the total number of 1's in the decimal form of the integers from 1 to N. For example, given N bein...
2018-09-07 17:44:18 229
转载 从1到n整数中1出现的次数:O(logn)算法
原文链接: https://blog.csdn.net/yi_Afly/article/details/520125931. 题目描述输入一个整数n,求从1到n这n个整数的十进制表示中1出现的次数。例如输入12,从1到12这些整数中包含1的数字有1,10,11和12,1一共出现了5次。2. 题目来源第一次看到是在《剑指Offer》第2版上,面试题32。leetcode和牛客网上都有...
2018-09-06 22:24:22 467
原创 PAT甲级 1048 Find Coins(25 分)hash散列/map
1048 Find Coins(25 分)Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of coin...
2018-09-06 21:22:37 114
原创 1047 Student List for Course(25 分)不定长数组vector,STL的使用
1047 Student List for Course(25 分)Zhejiang University has 40,000 students and provides 2,500 courses. Now given the registered course list of each student, you are supposed to output the student nam...
2018-09-06 19:40:32 116
原创 PAT甲级 1046 Shortest Distance(20 分)模拟,简便运算
1046 Shortest Distance(20 分)The task is really simple: given N exits on a highway which forms a simple cycle, you are supposed to tell the shortest distance between any pair of exits.Input Specifi...
2018-09-06 15:27:44 250
原创 PAT甲级 1045 Favorite Color Stripe(30 分)动态规划
1045 Favorite Color Stripe(30 分)Eva is trying to make her own color stripe out of a given one. She would like to keep only her favorite colors in her favorite order by cutting off those unwanted ...
2018-09-06 10:53:08 151
原创 PAT甲级 1044 Shopping in Mars(25 分)二分查找
1044 Shopping in Mars(25 分)Shopping in Mars is quite a different experience. The Mars people pay by chained diamonds. Each diamond has a value (in Mars dollars M$). When making the payment, the chai...
2018-09-04 19:32:34 164
转载 KMP算法最浅显理解——一看就明白
原文内容比较完整,链接: https://blog.csdn.net/starstar1992/article/details/54913261/算法说明一般匹配字符串时,我们从目标字符串str(假设长度为n)的第一个下标选取和ptr长度(长度为m)一样的子字符串进行比较,如果一样,就返回开始处的下标值,不一样,选取str下一个下标,同样选取长度为n的字符串进行比较,直到str的末尾(实际...
2018-09-04 11:22:24 141
原创 PAT甲级 1043 Is It a Binary Search Tree(25 分)
1043 Is It a Binary Search Tree(25 分)A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys ...
2018-09-03 20:16:13 99
原创 PAT甲级 1033 To Fill or Not to Fill(25 分)贪心算法
1033 To Fill or Not to Fill(25 分)With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the ...
2018-09-03 10:40:07 249
吴恩达2014机器学习作业(全部完整!!!作业全部代码已补全且运行结果无误!!!)
2018-06-20
吴恩达机器学习作业(完整版!!亲自做过!)
2018-05-29
Python网络数据采集
2018-04-27
机器学习实战源代码
2018-04-27
机器学习实战
2018-04-27
Effective C++中文版
2018-04-27
OpenCV3-毛星云编程入门
2018-04-27
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人