![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PAT
文章平均质量分 61
littlefox993
天道酬勤,但问耕耘。
展开
-
PAT乙级:1026 程序运行时间(15)(15 分)(四舍五入round()函数)
要获得一个C语言程序的运行时间,常用的方法是调用头文件time.h,其中提供了clock()函数,可以捕捉从程序开始运行到clock()被调用时所耗费的时间。这个时间单位是clock tick,即“时钟打点”。同时还有一个常数CLK_TCK,给出了机器时钟每秒所走的时钟打点数。于是为了获得一个函数f的运行时间,我们只要在调用f之前先调用clock(),获得一个时钟打点数C1;在f执行完成后再调用c...原创 2018-08-06 11:43:23 · 152 阅读 · 0 评论 -
PAT 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 Specification:Each input file conta...原创 2018-09-03 10:11:48 · 136 阅读 · 0 评论 -
PAT 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 way from time to time. Different ga...原创 2018-08-29 15:50:40 · 148 阅读 · 0 评论 -
PAT 1083 List Grades(25 分)(排序)
Given a list of N student records with name, ID and grade. You are supposed to sort the records with respect to the grade in non-increasing order, and output those student records of which the grades ...原创 2018-08-29 19:49:49 · 177 阅读 · 0 评论 -
PAT 1146 Topological Order(25 分)(拓扑排序)
This is a problem given in the Graduate Entrance Exam in 2018: Which of the following is NOT a topological order obtained from the given directed graph? Now you are supposed to write a program to test...原创 2018-09-01 13:17:09 · 195 阅读 · 0 评论 -
PAT 1133 Splitting A Linked List(25 分)(结构体+链表)
Given a singly linked list, you are supposed to rearrange its elements so that all the negative values appear before all of the non-negatives, and all the values in [0, K] appear before all those grea...原创 2018-09-04 13:27:59 · 164 阅读 · 0 评论 -
PAT 1132 Cut Integer(20 分)(字符串)
Cutting an integer means to cut a K digits lone integer Z into two integers of (K/2) digits long integers A and B. For example, after cutting Z = 167334, we have A = 167 and B = 334. It is interesting...原创 2018-09-04 13:27:45 · 157 阅读 · 0 评论 -
PAT 1145 Hashing - Average Search Time(25 分)(哈希+平均查找时间)
The task of this problem is simple: insert a sequence of distinct positive integers into a hash table first. Then try to find another sequence of integer keys from the table and output the average sea...原创 2018-09-04 13:27:08 · 242 阅读 · 0 评论 -
PAT 1013 Battle Over Cities(25 分)(dfs)
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 nee...原创 2018-09-04 13:26:50 · 128 阅读 · 0 评论 -
PAT 1028 List Sorting(25 分)(排序)
Excel can sort records according to any column. Now you are supposed to imitate this function.Input Specification:Each input file contains one test case. For each case, the first line contains two...原创 2018-09-01 14:19:17 · 135 阅读 · 0 评论 -
PAT 1069 The Black Hole of Numbers(20 分)(do while循环)
For any 4-digit integer except the ones with all the digits being the same, if we sort the digits in non-increasing order first, and then in non-decreasing order, a new number can be obtained by takin...原创 2018-09-01 14:21:42 · 89 阅读 · 0 评论 -
PAT 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 number of test cases, T (≤10). The...原创 2018-09-01 14:35:54 · 172 阅读 · 0 评论 -
PAT 1041 Be Unique(20 分)(哈希)
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 o...原创 2018-09-01 14:39:38 · 175 阅读 · 0 评论 -
PAT 1035 Password(20 分)(字符串+switch case + vector)
To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L ...原创 2018-09-04 13:27:18 · 133 阅读 · 0 评论 -
PAT 1019 General Palindromic Number(20 分)(进制转换+回文)
A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers...原创 2018-08-31 13:18:39 · 151 阅读 · 0 评论 -
PAT 1077 Kuchiguse(20 分)(reverse()函数)
The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker's personality. Such a preference is called ...原创 2018-08-31 13:12:47 · 185 阅读 · 0 评论 -
PAT 1062 Talent and Virtue(25 分)(vector+排序)
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 outstanding in both talent and virt...原创 2018-08-31 12:55:38 · 91 阅读 · 0 评论 -
PAT乙级:1016 部分A+B(15 分)
正整数 A 的“DA(为 1 位整数)部分”定义为由 A 中所有 DA 组成的新整数 PA。例如:给定 A=3862767,DA=6,则 A 的“6 部分”PA 是 66,因为 A 中有 2 个 6。现给定 A、DA、B、DB,请编写程序计算 PA+PB。输入格式:输入在一行中依次给出 A、DA、B、DB,中间以空格分隔...原创 2018-08-06 13:08:32 · 111 阅读 · 0 评论 -
PAT乙级:1083 是否存在相等的差(20 分)
给定 N 张卡片,正面分别写上 1、2、……、N,然后全部翻面,洗牌,在背面分别写上 1、2、……、N。将每张牌的正反两面数字相减(大减小),得到 N 个非负差值,其中是否存在相等的差?输入格式:输入第一行给出一个正整数 N(2 ≤ N ≤ 10 000),随后一行给出 1 到 N 的一个洗牌后的排列,第 i 个数表示正面写了 i 的那张卡片背面的数字。输出格式:按照“差值 ...原创 2018-08-12 18:37:41 · 168 阅读 · 0 评论 -
PAT乙级:1082 射击比赛(20 分)
本题目给出的射击比赛的规则非常简单,谁打的弹洞距离靶心最近,谁就是冠军;谁差得最远,谁就是菜鸟。本题给出一系列弹洞的平面坐标(x,y),请你编写程序找出冠军和菜鸟。我们假设靶心在原点(0,0)。输入格式:输入在第一行中给出一个正整数 N(≤ 10 000)。随后 N 行,每行按下列格式给出:ID x y其中 ID 是运动员的编号(由 4 位数字组成);x 和 y 是其打出的弹洞...原创 2018-08-12 18:45:52 · 187 阅读 · 0 评论 -
PAT乙级:1077 互评成绩计算(20 分)
在浙大的计算机专业课中,经常有互评分组报告这个环节。一个组上台介绍自己的工作,其他组在台下为其表现评分。最后这个组的互评成绩是这样计算的:所有其他组的评分中,去掉一个最高分和一个最低分,剩下的分数取平均分记为 G1;老师给这个组的评分记为 G2。该组得分为 (G1+G2)/2,最后结果四舍五入后保留整数分。本题就要求你写个程序帮助老师计算每个组的互评成绩。输入格式:...原创 2018-08-12 19:20:43 · 170 阅读 · 0 评论 -
练习集 L2-027 名人堂与代金券(25 分)(排序+排名)
对于在中国大学MOOC(http://www.icourse163.org/)学习“数据结构”课程的学生,想要获得一张合格证书,总评成绩必须达到 60 分及以上,并且有另加福利:总评分在 [G, 100] 区间内者,可以得到 50 元 PAT 代金券;在 [60, G) 区间内者,可以得到 20 元PAT代金券。全国考点通用,一年有效。同时任课老师还会把总评成绩前 K 名的学生列入课程“名人堂”。...原创 2018-08-30 18:55:58 · 140 阅读 · 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 su...原创 2018-08-30 19:04:53 · 112 阅读 · 0 评论 -
PAT 1078 Hashing(25 分)(哈希+平方探测法)
The task of this problem is simple: insert a sequence of distinct positive integers into a hash table, and output the positions of the input numbers. The hash function is defined to be H(key)=key%TSiz...原创 2018-08-30 19:17:59 · 399 阅读 · 0 评论 -
PAT 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 segments: (0.1) (0.1, 0.2) (0.1, 0.2, 0.3...原创 2018-08-31 10:49:19 · 98 阅读 · 0 评论 -
PAT 1085 Perfect Sequence(25 分)(二分)
Given a sequence of positive integers and another positive integer p. The sequence is said to be a perfect sequence if M≤m×pwhere M and m are the maximum and minimum numbers in the sequence, respectiv...原创 2018-08-31 10:56:52 · 237 阅读 · 0 评论 -
PAT 1038 Recover the Smallest Number(30 分)(头文件#include<string>)
Given a collection of number segments, you are supposed to recover the smallest number from them. For example, given { 32, 321, 3214, 0229, 87 }, we can recover many numbers such like 32-321-3214-0229...原创 2018-08-31 11:01:47 · 100 阅读 · 0 评论 -
PAT 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 use? For example, to sort {4, 0, 2...原创 2018-08-31 11:07:39 · 271 阅读 · 0 评论 -
PAT 1037 Magic Coupon(25 分)(贪心)
The magic shop in Mars is offering some magic coupons. Each coupon has an integer N printed on it, meaning that when you use this coupon with a product, you may get N times the value of that product b...原创 2018-08-31 11:16:10 · 250 阅读 · 0 评论 -
PAT 1025 PAT Ranking(25 分)(排序+排名)
1025 PAT Ranking(25 分)Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run simultaneously in several pla...原创 2018-08-31 11:20:35 · 1236 阅读 · 0 评论 -
PAT 1012 The Best Rank(25 分)(排序)
To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C - C Programming Language, M - Mathematics (Calculus or Linear Algrbra), and E - Eng...原创 2018-08-31 11:24:57 · 354 阅读 · 0 评论 -
PAT 1022 Digital Library(30 分)(字符串查找+vector+结构体)
A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is assigned an unique 7-digit number a...转载 2018-09-05 18:42:41 · 144 阅读 · 0 评论