PAT
chamsu
这个作者很懒,什么都没留下…
展开
-
PAT 1060 Are They Equal
Problem Description:If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved as 0.123*105 with simple chopping. Now given t原创 2013-08-01 15:52:34 · 687 阅读 · 0 评论 -
PAT 1020 Tree Traversals
题目的目的是很简单明了的,就是给定一棵二叉树的后序序列和中序序列,要求我们给出层次遍历的序列。本题的关键点在于二叉树的重建和层次遍历。本题是利用后序序列和中序序列来进行二叉树的重建,参考函数如下:Node * rebuild(int *post,int *in,int len ){ if(len == 0) return NULL; //判断是否为空树原创 2013-08-03 14:20:45 · 573 阅读 · 0 评论 -
PAT 1004 Counting Leaves
最近刚开始做PAT的练习题,太久没敲题目,手和脑袋都生锈了.本题的题意就是要我们在family tree族谱上找出同一辈(与根节点距离相等的节点)没有child的节点个数.博主在做这道题时用的是广搜+连接表;主要注意的地方在于:输入的节点编号不一定是连续的;父节点的编号不一定小于子节点的编号;参考代码如下,大牛勿喷:#includeint main(){ int n,m,l[110]={0}原创 2013-08-02 12:33:26 · 689 阅读 · 0 评论 -
PAT 1049 Counting Ones
The task is simple: given any positive integer N, you are supposed to count the total number of 1's in the decimal form of the integers from 1 to N. For example, given N being 12, there are five 1's i原创 2013-08-05 15:25:13 · 701 阅读 · 0 评论 -
PAT 1073 Scientific Notation
#include#includeint main(){ int i,j,cnt=0,sum=0,len; char num[100000],temp[100000],sign_n,sign_e,neg='-'; scanf("%s",num);len=strlen(num); sign_n=num[0]; for(i=1,j=0;i原创 2015-03-01 15:19:12 · 573 阅读 · 0 评论 -
PAT 1003 Emergency
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 l原创 2015-03-03 14:30:22 · 557 阅读 · 0 评论 -
PAT 1010. Radix (25)
Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is "yes", if 6 is a decimal number and 110 is a binary number.Now for any pair of positive原创 2014-07-07 20:54:38 · 518 阅读 · 0 评论 -
PAT 1040 Longest Symmetric String
Given a string, you are supposed to output the length of the longest symmetric sub-string. For example, given "Is PAT&TAP symmetric?", the longest symmetric sub-string is "s PAT&TAP s", hence you must原创 2016-12-27 17:18:16 · 484 阅读 · 0 评论