
PAT考试
开发学习实录
这个作者很懒,什么都没留下…
展开
-
PAT 1009 Product of Polynomials (25 分)
PAT 1009 Product of Polynomials (25 分) 多项式链表的乘积 用链表L1的每一个节点和链表L2的每一个节点相乘之后进行加和,生成新的结果链表 具体代码 #include<iostream> #include<malloc.h> #include<iomanip> using namespace std; typedef struct node* Node; struct node { int exp; float cof; Nod原创 2021-02-13 18:37:11 · 98 阅读 · 0 评论 -
PAT 1008 Elevator (20 分)
1008 Elevator (20 分) 简单题,读懂题目就好 具体代码 #include<iostream> #include<vector> using namespace std; int main() { int n; int sum = 0; cin >> n; vector<int> v(n+2); v[0] = 0; for (int i = 1; i <=n; i++) { cin >> v[i]; }原创 2021-02-13 18:31:18 · 76 阅读 · 0 评论 -
PAT 1007 Maximum Subsequence Sum (25 分)
1007 Maximum Subsequence Sum (25 分) 经典题 具体代码 #include<iostream> #include<malloc.h> using namespace std; #define maxsize 100001 int main() { int n; int number[maxsize + 1]; bool flag = true; int max = 0;//记录整个比较过程中的最大值 int tmp = 0;//短暂的记录变原创 2021-02-13 18:29:33 · 132 阅读 · 0 评论 -
PAT 1006 Sign In and Sign Out (25 分)
PAT 1006 Sign In and Sign Out (25 分) #include<iostream> #include<malloc.h> using namespace std; int main() { string come_time, leave_time; //设置初始值 string min = "23:59:59"; string max = "00:00:00"; string name; string name1,name2; int原创 2021-02-13 18:11:55 · 72 阅读 · 0 评论 -
PAT 1005 Spell It Right (20 分)
1005 Spell It Right (20 分) 思路分析 主要是由于输入的整数过大,超出了整数型定义的类型,所以将它转化为字符型来处理 具体的代码 #include<iostream> #include<malloc.h> #include<string> #include<sstream>//将整型转化为字符串类型 using namespace std; int main() { string s[10]; string s1,s2; str原创 2021-02-13 18:07:35 · 86 阅读 · 0 评论 -
PAT 1004 Counting Leaves (30 分)
PAT 1004 Counting Leaves (30 分) 思路分析 1、主要做的就是如何存储整个树的信息,要知道本题的树并非是常规的二叉树 2、可以考虑采用 struct node【maxsize】来整体记录 3、需要注意的是M行的父节点数字并非是按照顺序给出的,可以是乱序的状态 具体的代码展示 #include<iostream> #include<malloc.h> #include<vector> using namespace std; //首先是采用一个结原创 2021-02-13 14:08:10 · 98 阅读 · 0 评论 -
PAT 1003 Emergency (25 分)
1003 Emergency (25 分) 易错点以及思路的梳理 总体上来说就是dijkstra算法的变形,也就是说原始的版本判断是否是加入边的时候,只是考虑到达源点的距离大小来进行更新,在本题中加入了第二条判断法制,也就是考虑该城市的队伍数量。 具体来说 1、记录不同的最短路径 2、在选取的路径长度相同时,进一步考虑所能召集的城市队伍数量 代码展示 #include<iostream> #include<malloc.h> #include<iomanip> #incl原创 2021-02-08 22:50:50 · 95 阅读 · 0 评论 -
1002 A+B for Polynomials (25 分)
1002 A+B for Polynomials (25 分) 难点分析 1.要考虑到当输入项的指数相同的时候,其系数相加有可能为零 2.当你对两个链表继续提取的时候,在循环处理中,你要处理好有可能有一个链表提前就移动到尾部了 3.在这里有一个特殊的语法,也就是在c++中如何保留到小数点后一位 头部库是 #include<iomanip> 具体的语法是 cout.setf(ios::fixed);cout << " " << setprecision(1) <&l原创 2021-02-05 22:25:39 · 254 阅读 · 1 评论 -
1001 A+B Format (20 分)
1001 A+B Format (20 分) 整体的梳理 主要是对于整形的数字如何快速且简单的输出其数位上的数字,并且合理的将加和的结果以三个字符为一个片段输出 完整的题目介绍 1.content 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原创 2021-02-05 12:43:41 · 92 阅读 · 0 评论