- 博客(26)
- 资源 (9)
- 收藏
- 关注
原创 PAT甲级 1115 Counting Nodes in a BST (30 分)bst
1115 Counting Nodes in a BST (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 keys le...
2018-11-29 21:14:55 159
原创 PAT甲级 1113 Integer Set Partition (25 分)数学问题
1113 Integer Set Partition (25 分)Given a set of N (>1) positive integers, you are supposed to partition them into two disjoint sets A1 and A2 of n1and n2 numbers, respectively. Let S...
2018-11-29 16:49:10 141
原创 PAT甲级 1112 Stucked Keyboard (20 分)
1112 Stucked Keyboard (20 分)On a broken keyboard, some of the keys are always stucked. So when you type some sentences, the characters corresponding to those keys will appear repeatedly on screen fo...
2018-11-29 15:35:49 188
原创 PAT甲级 1110 Complete Binary Tree (25 分)完全二叉树、dfs
1110 Complete Binary Tree (25 分)Given a tree, you are supposed to tell if it is a complete binary tree.Input Specification:Each input file contains one test case. For each case, the first line g...
2018-11-29 10:32:23 175
原创 PAT甲级 1108 Finding Average (20 分)字符串处理
1108 Finding Average (20 分)The basic task is simple: given N real numbers, you are supposed to calculate their average. But what makes it complicated is that some of the input numbers might not be l...
2018-11-25 21:27:06 226
原创 sscanf与sprintf用法
参考链接:https://blog.csdn.net/sim120/article/details/22872885sscanf: 从字符串中拆分出想要的类型sprintf: 把各种类型的东西合成一个字符串示例代码如下:#include <stdio.h> int main(void){ char buf[20] = "1:23:abc"; in...
2018-11-25 17:47:58 170
原创 PAT甲级 1106 Lowest Price in Supply Chain (25 分)dfs
1106 Lowest Price in Supply Chain (25 分)A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Start...
2018-11-24 17:35:31 177
原创 PAT甲级 1105 Spiral Matrix (25 分)模拟
1105 Spiral Matrix (25 分)This time your job is to fill a sequence of N positive integers into a spiral matrix in non-increasing order. A spiral matrix is filled in from the first element at the uppe...
2018-11-24 11:51:14 190
原创 给定一个数和一个数组,在数组中找到两个值之和为给定数,显示所有情况,要求复杂度为O(n)
首先对数组进行排序,时间复杂度为(N*log2N)。然后令i = 0,j = n-1,看arr[i] + arr[j] 是否等于Sum,如果是,则结束。如果小于Sum,则i = i + 1;如果大于Sum,则 j = j – 1。这样只需要在排好序的数组上遍历一次,就可以得到最后的结果,时间复杂度为O(N)。两步加起来总的时间复杂度O(N*log2N),下面这个程序就利用了这个思想,代码如下所...
2018-11-20 22:41:53 1496
原创 PAT甲级 1102 Invert a Binary Tree (25 分)树的遍历(bfs+dfs)
1102 Invert a Binary Tree (25 分)The following is from Max Howell @twitter:Google: 90% of our engineers use the software you wrote (Homebrew), but you can't invert a binary tree on a whiteboard so...
2018-11-20 18:20:59 164
原创 PAT甲级 1104 Sum of Number Segments (20 分)数学问题
1104 Sum of Number Segments (20 分)Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence { 0.1, 0.2, 0.3, 0.4 }, we have 10 segme...
2018-11-20 17:11:46 155
原创 PAT甲级 1100 Mars Numbers (20 分)map、string
1100 Mars Numbers (20 分)People on Mars count their numbers with base 13:Zero on Earth is called "tret" on Mars. The numbers 1 to 12 on Earch is called "jan, feb, mar, apr, may, jun, jly, aug, sep...
2018-11-20 16:30:59 180
原创 PAT甲级 1096 Consecutive Factors (20 分)
1096 Consecutive Factors (20 分)Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be factored as 3×5×6×7, where 5, 6, and 7 are the thre...
2018-11-18 21:15:06 160
原创 PAT甲级 1095 Cars on Campus (30 分)排序
参考链接:https://www.liuchuo.net/archives/29511095 Cars on Campus (30 分)Zhejiang University has 8 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers of t...
2018-11-18 16:45:48 309
原创 PAT甲级 1101 Quick Sort (25 分) 快排
1101 Quick Sort (25 分)There is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one element as the pivot. Then the elements less than the p...
2018-11-17 12:07:38 212
原创 1099 Build A Binary Search Tree (30 分)dfs、bfs、bst
1099 Build A 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 keys...
2018-11-12 11:52:01 248
原创 PAT甲级 1097 Deduplication on a Linked List (25 分)链表
1097 Deduplication on a Linked List (25 分)Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each value K,...
2018-11-09 22:41:32 188
原创 PAT甲级 1094 The Largest Generation (25 分)BFS,树的宽度
1094 The Largest Generation (25 分)A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation ...
2018-11-09 22:36:59 143
原创 1091 Acute Stroke (30 分)BFS
1091 Acute Stroke (30 分)One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the results of image analysis in which the core regions are identified in each M...
2018-11-08 16:42:08 513
原创 PAT甲级 1093 Count PAT's (25 分)逻辑题
参考链接:https://www.liuchuo.net/archives/18961093 Count PAT's (25 分)The string APPAPT contains two PAT's as substrings. The first one is formed by the 2nd, the 4th, and the 6th characters, and the se...
2018-11-07 20:10:34 313
原创 百度iOS面试题 打印1-100的所有素数(各种优化版)
参考链接:https://www.cnblogs.com/ray-coding-in-rays/p/6143201.html打印素数表的四种方法题目:给出一个正整数n,打印出所有从1~n的素数(即质数); 1.傻瓜解法1 int i,n;2 while(scanf("%d",&n)!=EOF)3 { 4 for(i=2;i<n;...
2018-11-06 15:36:01 699
原创 PAT甲级 1092 To Buy or Not to Buy (20 分)hash散列
1092 To Buy or Not to Buy (20 分)Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy some beads. There were many colorful strings of beads. However th...
2018-11-05 20:13:29 137
原创 PAT甲级 1089 Insert or Merge (25 分)排序模拟(直插排序与非递归归并排序)
1089 Insert or Merge (25 分)According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one...
2018-11-05 15:26:58 212
原创 PAT甲级 1090 Highest Price in Supply Chain (25 分)dfs (树的遍历)
1090 Highest Price in Supply Chain (25 分)A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Star...
2018-11-04 15:05:31 133
原创 直接插入排序
时间复杂度:O(n的平方) 空间复杂度:O(1)#include <iostream>#include <vector>using namespace std;vector<int> arr,temp;void insertSort(vector<int> &arr,int n){ int i,j; fo...
2018-11-04 10:17:15 95
原创 PAT甲级 1088 Rational Arithmetic (20 分)数学运算
1088 Rational Arithmetic (20 分)For two rational numbers, your task is to implement the basic arithmetics, that is, to calculate their sum, difference, product and quotient.Input Specification:Ea...
2018-11-03 11:45:28 124
吴恩达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关注的人