PAT
Caohengpy
小白
展开
-
PAT甲级1002(C语言)
1002 A+B for Polynomials (25 分)This time, you are supposed to find A+B where A and B are two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 lines, a...原创 2019-03-30 14:35:50 · 614 阅读 · 0 评论 -
PAT甲级1007(C语言)
题目大意:串中的最大和字串,若有两个相同的和,则输出最大字串中下标最小的起点和终点的值。若串中全为负数,则最大和为0,输出串的起点和终点的值。串中除0以外全为负数则应该输出第一个0出现的位置上的值(0)。解题思路:第一种情况和第二种情况比较好处理,通过在线更新下标和最大值的方法来处理。**需要注意一下第三种情况,可以在遍历串的时候统计一下负数与正数,来判断是否满足第三种情况(即正数...原创 2019-04-19 00:06:42 · 639 阅读 · 0 评论 -
PAT甲级1009(C语言)
题目大意:求两个多项式的乘积,即指数相加,系数相乘,最后合并同类项。解题思路:创建一个结构体:typedef struct Node {float coe;//系数int exp;//指数}Node;遍历结构体数组,将乘积结果存放在一个新的结构体数组中,并将新的结构体按照指数从大到小的顺序排序。之后合并同类项,最后还需要将系数为0的从结构体数组中删除。代码:#inclu...原创 2019-04-22 14:43:38 · 375 阅读 · 0 评论 -
PAT甲级1006(C语言)
1006 Sign In and Sign Out (25 分)At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door. Given the reco...原创 2019-04-16 12:52:14 · 802 阅读 · 2 评论 -
PAT甲级1003(C语言)
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...原创 2019-04-09 00:08:20 · 962 阅读 · 0 评论 -
PAT甲级1005(C语言)
1005 Spell It Right (20 分)Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English.Input Specification:Each input file...原创 2019-04-15 17:26:12 · 490 阅读 · 0 评论 -
PAT甲级1001(c语言)
PAT甲级第一次写搞忘了输出格式%03d(不足三位左补零)以下是比较蠢的代码:情况一(特殊处理):情况二:第一次写搞忘了输出格式%03d(不足三位左补零)以下是比较蠢的代码:#include<stdio.h>#include<math.h>int main(){ int a, b; int sum; int r, c, r1, c1;//r 为商,c为余数,...原创 2019-03-28 20:12:12 · 912 阅读 · 2 评论 -
PAT甲级1004(C语言)
1004 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:Each input file contains on...原创 2019-04-10 20:21:33 · 642 阅读 · 0 评论 -
PAT甲级1008(C语言)
题目大意:要求输入N,接下来N个数表示电梯的运行顺序。电梯上一层+6s,下一层+4s,每层停留时间为5s。解题思路:一开始没看清这句话“Each case contains a positive integer N, followed by N positive numbers”,误以为给出的输入序列为电梯运行的顺序导致出错。其实这道题很简单,总停留时间 = N5,电梯上行还是下行只要判断...原创 2019-04-19 23:34:45 · 491 阅读 · 0 评论