PAT甲级题库
文章平均质量分 79
详细记录题解思路和注意事项
YJDDUP
在真理面前得寸进尺
展开
-
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 legal. A legal input is a real number in [−1000,1000] and is accurate up to no more th原创 2020-07-14 00:54:46 · 128 阅读 · 0 评论 -
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 upper-left corner, then move in a clockwise spiral. The matrix has m rows and n columns原创 2020-07-12 02:36:56 · 273 阅读 · 0 评论 -
1102 Invert a Binary Tree (25分)树的遍历
题意理解 给定以序号代表结点的二叉树,输出这个二叉树的反转层序遍历和反转中序遍历 数据结构 因为n个结点用序号0到n-1代表,所以考虑用相对于链表更加简单的静态链表来实现二叉树,即一个结构体数组。 struct Node{ int left;//设置非法值为-1 int right; }BiTree[maxn]; 解题思路 所谓反转二叉树就是原二叉树的左右镜像 输入中未出现的结点便是根结点,需要设置一个数组来标记出现的结点,输入结束后遍历此数组,未被标记的结点即为根节点 反转二叉树的层序.原创 2020-07-10 23:22:39 · 158 阅读 · 0 评论