Pta
文章平均质量分 65
-白羊-
这个作者很懒,什么都没留下…
展开
-
PTA甲级——1036 Boys vs Girls (25分)
This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students.Input Specification:Each input file contains one test case. Each case contains a positive integer N, followe原创 2021-01-17 16:04:28 · 108 阅读 · 0 评论 -
PAT甲级——1092 To Buy or Not to Buy
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 the owner of the shop would only sell the strings in whole pieces. Hence Eva must check whet原创 2020-11-22 01:06:25 · 121 阅读 · 0 评论 -
PTA甲级——树的同构 (25分)
给定两棵树T1和T2。如果T1可以通过若干次左右孩子互换就变成T2,则我们称两棵树是“同构”的。例如图1给出的两棵树就是同构的,因为我们把其中一棵树的结点A、B、G的左右孩子互换后,就得到另外一棵树。而图2就不是同构的。[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-UdcdtWph-1605802792125)(~/28)]图1图2现给定两棵树,请你判断它们是否是同构的。输入格式:输入给出2棵二叉树树的信息。对于每棵树,首先在一行中给出一个非负整数N (≤10),原创 2020-11-22 00:57:30 · 203 阅读 · 0 评论 -
PTA甲级——7-5 Counting Leaves (30分)
A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.Input Specification:The input consists of several test cases, each starts with a line containing 0<N<100, the number of nodes in原创 2020-11-20 00:14:54 · 220 阅读 · 0 评论 -
PTA甲级——Be Unique
Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a number chosen from [1,104]. The first one who bets on a unique number wins. For example, if there are 7 peop原创 2020-11-19 23:16:21 · 455 阅读 · 0 评论 -
1003 Emergency——Dijkstra
1003 Emergency (25分)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 length of each road between any pair原创 2020-10-15 22:52:38 · 185 阅读 · 0 评论 -
PAT甲级——A+B Format
题外话:好久好久好久没有刷甲级的题目了,十分愧疚,从今天起,坚持打卡。题目如下Calculate a+b and 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:Each input file contains one原创 2020-10-10 23:21:02 · 116 阅读 · 0 评论 -
7-3 白骑士的移动 (20分)
小S第一次接触国际象棋。他发现国际象棋中的Knight棋子的移动方式和中国象棋中的马类似,移动方式如图所示。 QQ图片20191115182554.png于是小S在棋盘上随意摆上了一些棋子,其中包括一枚白骑士、一枚黑皇后、若干黑战车和若干黑主教。小S想知道,如何能在避开黑战车和黑主教的攻击范围的前提下,花费更少的步数吃掉黑皇后。注1:战车的攻击范围呈直线,和中国象棋的車类似;主教的攻击范围呈...原创 2020-05-06 23:23:19 · 246 阅读 · 0 评论 -
6-3 删除单链表偶数节点 (20分)
本题要求实现两个函数,分别将读入的数据存储为单链表、将链表中偶数值的结点删除。链表结点定义如下:struct ListNode {int data;struct ListNode *next;};函数接口定义:struct ListNode *createlist();struct ListNode *deleteeven( struct ListNode *head );函数cr...原创 2020-04-17 18:16:53 · 2266 阅读 · 0 评论 -
7-1 两个有序链表序列的交集 (20分)
已知两个非降序链表序列S1与S2,设计函数构造出S1与S2的交集新链表S3。输入格式:输入分两行,分别在每行给出由若干个正整数构成的非降序序列,用−1表示序列的结尾(−1不属于这个序列)。数字用空格间隔。输出格式:在一行中输出两个输入序列的交集序列,数字间用空格分开,结尾不能有多余空格;若新链表为空,输出NULL。输入样例:1 2 5 -12 4 5 8 10 -1输出样例:2...原创 2020-04-17 17:35:30 · 1389 阅读 · 0 评论