
c
文章平均质量分 68
DedicateToAI
这个作者很懒,什么都没留下…
展开
-
6.S081 Lab util: Unix utilities
primes(moderate)/(hard)Write a concurrent version of prime sieve using pipes. This idea is due to Doug McIlroy, inventor of Unix pipes. The picture halfway downthis pageand the surrounding text explain how to do it. Your solution should be in the file...原创 2021-12-03 00:51:30 · 366 阅读 · 1 评论 -
总结与反思 - 12月7日冬季PAT甲级考试
第一次参加PAT甲级考试,地点在上海大学计算中心。首先要说下这个位置,地图上没有明显的标识,准考证上也没有明确的写,最后是靠自己问路问来的。上海大学计算中心:首先找到图书馆附近,然后找D楼,D楼的4楼就是计算中心啦。然后说下环境,机房是比较老的了,不过看上去编译环境还是比较齐全的,python, java, c都有,因为自己之前一直是用的VS2019,这次也打开了vs2010,然后就被坑...原创 2019-12-12 11:25:04 · 325 阅读 · 0 评论 -
PAT甲级简单题最后冲刺
A1001Calculatea+band output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits).Input Specification:Eac...原创 2019-12-07 00:03:16 · 455 阅读 · 0 评论 -
PAT甲级 - 1018 Public Bike Management (30分)
There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike at any station and return it to any other stations in the...原创 2019-12-06 19:24:22 · 214 阅读 · 0 评论 -
PAT甲级 - 1021 Deepest Root (25分)
A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you are supposed to find the root that results in a highest tree. Such a root...原创 2019-12-05 20:19:54 · 174 阅读 · 0 评论 -
PAT甲级 -1013 Battle Over Cities (25分) 求连通块的数量
It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are closed. We must know immediately if we ne...原创 2019-12-04 21:26:54 · 210 阅读 · 0 评论 -
PAT甲级 - 1098 Insertion or Heap Sort (25 分) 堆排序,找规律
According to Wikipedia:Insertion sortiterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data...原创 2019-12-04 11:25:04 · 250 阅读 · 0 评论 -
PAT甲级 - 1107 Social Clusters (30 分) 并查集
When register on a social network, you are always asked to specify your hobbies in order to find some potential friends with the same hobbies. Asocial clusteris a set of people who have some of the...原创 2019-12-02 21:58:30 · 195 阅读 · 0 评论 -
PAT甲级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 more than one, rebalancing i...原创 2019-12-02 18:12:43 · 190 阅读 · 0 评论 -
PAT甲级 - 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 less than the node's key. The right s...原创 2019-12-01 22:08:46 · 183 阅读 · 0 评论 -
PAT - 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 keys less than the node's key. The right s...原创 2019-12-01 21:32:08 · 195 阅读 · 0 评论 -
PAT甲级 - 1094 The Largest Generation (25 分) 树+DFS
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 with the largest population.Input...原创 2019-12-01 18:50:36 · 165 阅读 · 0 评论 -
PAT甲级 - 1090 Highest Price in Supply Chain (25 分) 树+DFS
A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on t...原创 2019-12-01 18:12:56 · 200 阅读 · 0 评论 -
PAT甲级 - 1079 Total Sales of Supply Chain (25 分) 树+BFS
A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on t...原创 2019-11-30 21:51:08 · 252 阅读 · 0 评论 -
PAT甲级 - 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 fuck off.Now it's your tur...原创 2019-11-30 19:40:32 · 233 阅读 · 1 评论 -
PAT甲级- 1086 Tree Traversals Again (25 分) 已知先序和中序,求后序
An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the keys numbered from 1 to 6) is traversed, the sta...原创 2019-11-30 18:09:44 · 185 阅读 · 0 评论 -
PAT甲级1105 Spiral Matrix (25 分) 模拟
This time your job is to fill a sequence ofNpositive integers into aspiral matrixin non-increasing order. A spiral matrix is filled in from the first element at the upper-left corner, then mov...原创 2019-11-29 21:48:27 · 176 阅读 · 0 评论 -
PAT甲级 - 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 top position) and P...原创 2019-11-28 23:16:36 · 275 阅读 · 0 评论 -
PAT甲级 - 1068 Find More Coins (30 分) DFS 和DP
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 coins as payments. However...原创 2019-11-28 20:42:09 · 208 阅读 · 0 评论 -
PAT甲级- 1040 Longest Symmetric String (25 分)
Given a string, you are supposed to output the length of the longest symmetric sub-string. For example, givenIs PAT&TAP symmetric?, the longest symmetric sub-string iss PAT&TAP s, hence you...原创 2019-11-27 21:49:49 · 198 阅读 · 0 评论 -
PAT甲级 -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 pieces and sewing the remaining p...原创 2019-11-27 20:30:00 · 237 阅读 · 0 评论 -
PAT甲级 1007 Maximum Subsequence Sum (25 分)
Given a sequence ofKintegers {N1,N2, ...,NK}. A continuous subsequence is defined to be {Ni,Ni+1, ...,Nj} where1≤i≤j≤K. The Maximum Subsequence is the continuous subse...原创 2019-11-24 22:44:39 · 149 阅读 · 0 评论 -
PAT甲级 - 1003 Emergency (25 分) Dijstra和BF算法
As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the ...原创 2019-11-15 12:35:45 · 246 阅读 · 0 评论 -
PAT - 1076 Forwards on Weibo (30 分) 图的BFS遍历
Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other users as well. Hence a social network is formed with followers relations. When a...原创 2019-11-13 23:14:25 · 182 阅读 · 0 评论 -
PAT- 并查集-好朋友
并查集的重点是维护一个father数组,来表明各结点间的关系【好朋友】1. 问题描述:有一个叫做“数码世界”奇异空间,在数码世界里生活着许许多多的数码宝贝,其中有些数码宝贝之间可能是好朋友,并且数码宝贝世界有两条不成文的规定:第一,数码宝贝A和数码宝贝B是好朋友等价于数码宝贝B与数码宝贝A是好朋友第二,如果数码宝贝A和数码宝贝C是好朋友,而数码宝贝B和数码宝贝C也是好朋友,那...原创 2019-11-12 21:48:09 · 390 阅读 · 0 评论 -
1053 Path of Equal Weight (30 分)
Given a non-empty tree with rootR, and with weightWiassigned to each tree nodeTi. Theweight of a path fromRtoLis defined to be the sum of the weights of all the nodes along the path fr...原创 2019-11-08 13:53:34 · 164 阅读 · 0 评论 -
PAT - 1020 Tree Traversals
Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level order traversal sequence of the co...原创 2019-11-08 10:49:29 · 135 阅读 · 0 评论 -
PAT - DFS
使用DFS可以解决枚举子序列问题:给定一个序列,枚举这个序列的所有子序列。因为每个数总有两种状态,选与不选,然后进行递归即可。枚举从N个整数中选择K个数的方案是子问题。例题:从序列A(n个数)中选K个数,使得和为x,且序列的平方和最大。 //有边界,提前判断//序列A中n个数选k个数使得和为x,最大平方和为maxSumSqu#include<cstdio>#incl...原创 2019-11-01 22:28:20 · 189 阅读 · 0 评论 -
PAT - 栈、队列、链表
【Codeup 1918】简单计算器数据结构node,用来存储操作数和操作符,flag来表示类型 stack操作符栈【遇到相等或者高优先级操作符,弹出】;queue用来存储转换成的后缀表达式;map实现操作符优先级的映射。 使用(getline(cin, str), str!= "0"),来输入若干字符串str,str = "0",终止输入。 使用 string::iterator i...原创 2019-10-31 22:05:11 · 319 阅读 · 0 评论 -
PAT - 数学类总结
PAT A 1069The Black Hole of Numbers(20分)学习点:1.整型数组和整数的相互转换,整型数组排序实现倒序2. %04d进行输出,实现缺0补0.#include<cstdio>#include<algorithm>using namespace std;bool cmp(int a, int b){ ...原创 2019-10-24 16:08:40 · 265 阅读 · 0 评论 -
1101 Quick Sort (25 分)- PAT甲级真题-多种算法及分析
There is a classical process namedpartitionin the famous quick sort algorithm. In this process we typically choose one element as the pivot. Then the elements less than the pivot are moved to its l...原创 2019-10-22 13:16:14 · 899 阅读 · 3 评论 -
贪心 - PAT B - 1020 月饼 (25 分)
#include<cstdio>#include<algorithm>using namespace std;struct cake{ double number; double total_price; double per_price;}mooncakes[1010];bool cmp(cake a, cake b){ r...原创 2019-10-18 22:08:25 · 166 阅读 · 0 评论 -
一些比较难懂的递归题目 c++
全排列问题#include<cstdio>const int maxn = 11;int n, P[maxn], hashTable[maxn] = { false };void generateP(int index) { if (index == n + 1) { for (int i = 1; i <= n; i++) { printf("%d"...原创 2019-10-18 15:53:55 · 548 阅读 · 0 评论 -
排序 - PAT甲级 1025 PAT Ranking (25 分) C / C++
#include<cstdio>#include<algorithm>#include<cstring>using namespace std;struct testee { char regis_num[15]; int score; int final_rank; int local_num; int local_rank;}tes...原创 2019-10-17 22:43:01 · 191 阅读 · 0 评论 -
GPS数据处理
题目内容:NMEA-0183协议是为了在不同的GPS(全球定位系统)导航设备中建立统一的BTCM(海事无线电技术委员会)标准,由美国国家海洋电子协会(NMEA-The National Marine Electronics Associa-tion)制定的一套通讯协议。GPS接收机根据NMEA-0183协议的标准规范,将位置、速度等信息通过串口传送到PC机、PDA等设备。 NMEA-0...原创 2018-03-15 11:58:21 · 1251 阅读 · 0 评论 -
单词长度
题目内容:你的程序要读入一行文本,其中以空格分隔为若干个单词,以‘.’结束。你要输出这行文本中每个单词的长度。这里的单词与语言无关,可以包括各种符号,比如“it's”算一个单词,长度为4。注意,行中可能出现连续的空格。 输入格式:输入在一行中给出一行文本,以‘.’结束,结尾的句号不能计算在最后一个单词的长度内。 输出格式:在一行中输出这行文本对应的单词的长度,每个长度之...原创 2018-03-12 10:37:54 · 431 阅读 · 0 评论 -
鞍点
题目内容:给定一个n*n矩阵A。矩阵A的鞍点是一个位置(i,j),在该位置上的元素是第i行上的最大数,第j列上的最小数。一个矩阵A也可能没有鞍点。你的任务是找出A的鞍点。 输入格式:输入的第1行是一个正整数n, (1<=n<=100),然后有n行,每一行有n个整数,同一行上两个整数之间有一个或多个空格。 输出格式:对输入的矩阵,如果找到鞍点,...原创 2018-03-10 11:38:58 · 512 阅读 · 0 评论 -
多项式加法
题目内容:一个多项式可以表达为x的各次幂与系数乘积的和,比如:2x6+3x5+12x3+6x+20现在,你的程序要读入两个多项式,然后输出这两个多项式的和,也就是把对应的幂上的系数相加然后输出。程序要处理的幂最大为100。 输入格式:总共要输入两个多项式,每个多项式的输入格式如下:每行输入两个数字,第一个表示幂次,第二个表示该幂次的系数,所有的系数都是整数。第一行一...原创 2018-03-09 23:05:11 · 377 阅读 · 0 评论 -
C语言程序设计进阶期末考试编程部分
1最小包围矩形(10分)题目内容:给定一组二维坐标,表示直角坐标系内的一个多边形的连续的顶点的坐标序列。计算能包围这个多边形的平行于坐标轴的最小矩形,输出它的左下角和右上角的坐标。 输入格式:第一行是一个正整数n表示顶点的数量,第二行是n组整数,依次表示每个顶点坐标的x和y值。 输出格式:四个整数,依次表示所计算的矩形的左下角的坐标的x、y值和右上角坐标的x、y...原创 2018-07-26 17:35:03 · 586 阅读 · 0 评论 -
逆序输出
题目内容:你的程序会读入一系列的正整数,预先不知道正整数的数量,一旦读到-1,就表示输入结束。然后,按照和输入相反的顺序输出所读到的数字,不包括最后标识结束的-1。 输入格式:一系列正整数,输入-1表示结束,-1不是输入的数据的一部分。 输出格式:按照与输入相反的顺序输出所有的整数,每个整数后面跟一个空格以与后面的整数区分,最后的整数后面也有空格。 输入样例:...转载 2018-07-25 22:51:37 · 708 阅读 · 0 评论