- 博客(23)
- 收藏
- 关注
原创 Copy Constructor (拷贝构造函数)的构造操作
可能使用拷贝构造函数的使用情景:1.使用一个object对另一个object做显示初始化的时候例:class X{....}int main(){ X x; ...... X xx=x;//调用拷贝构造函数}2.当object被当作参数,并且以值传递的方式传入例:class X{...}void func(X x);int main(...
2019-11-25 21:00:37
924
原创 UNIX文件共享
Unix系统支持在不同进程间共享打开文件内核使用3种数据结构表示打开文件,这三种结构的关系决定了共享文件进程间的可能产生的影响结构1.文件描述符表,文件描述符表存在于进程表的一个记录项中,文件描述符表中的每一项包含两个重要数据: a. 文件描述符标志 b.指向一个文件表项的指针结构2. 文件表项,文件表项存在于内核为所有打开文件维持的一张...
2019-11-18 16:12:49
1269
1
原创 文件I/O流程基础函数
函数creat作用:创建一个新文件(只以写方式打开创建的文件)#include<fcntl.h>int creat(const char *path ,mode_t mode);参数解释: path: 将要创建的文件路径 mode: 文件权限级别该函数成功则返回为只写打开的文件描述符,若出错则返回 -1该函数等效...
2019-11-17 20:18:38
174
原创 open()与openat()
open或openat函数都是打开或者创建一个文件的函数#include<fcntl.h>int open(const char *path, int aflag, .../*mode_t mode*/);int openat(int fd, const char *path, int aflag, .../*mode_t mode*/);参数介绍:path:要...
2019-11-16 20:30:36
3110
1
原创 c++ 默认构造函数总结
什么时候编译器会合成一个默认构造函数?答案:当编译器需要它的时候!(如果程序需要一个默认构造函数,那是程序员的责任,应该由程序员自己定义)并且被合成出来的构造函数只执行编译器所需的行动。注意:1.并非所有没有构造函数的类在编译时都会生成默认构造函数(但一些大学老师为了讲课方便就这么讲的)。 2.只有类中没有显示声明任何构造函数时,编译器才可能会为类生成默认构造函数...
2019-11-04 22:01:51
1599
原创 PAT 1021 Deepest Root (25 分)(最后两个测试点错误)燚
A graph which is connected and acyclic can be considered a tree. The hight of the tree depends on the selected root. Now you are supposed to find the root that results in a highest tree. Such a root i...
2018-12-15 21:38:36
2192
原创 PAT 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 t...
2018-12-01 18:33:08
202
原创 PAT 1060 Are They Equal (25 分)(关于测试点4与6错误) 极端测试样例 燚
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 the number of signif...
2018-12-01 18:12:26
1915
3
原创 PAT 1029 Median (25 分) 燚
Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1 = { 11, 12, 13, 14 } is 12, and the median of S2 = { 9, 10, 15, 16, 17 } is...
2018-11-28 22:27:31
255
原创 PAT 1125 Chain the Ropes (25 分)贪心算法 结果向下取整(题目有歧义) 燚
Given some segments of rope, you are supposed to chain them into one rope. Each time you may only fold two segments into loops and chain them into one piece, as shown by the figure. The resulting chai...
2018-11-26 23:09:36
288
原创 PAT 1104 Sum of Number Segments (20 分) 数列阶梯式相加(AC的代码 和 有错误的代码) 燚
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-11-26 11:02:05
284
1
原创 PAT 1128 N Queens Puzzle (20 分) 等腰三角形的应用 燚
The "eight queens puzzle" is the problem of placing eight chess queens on an 8×8 chessboard so that no two queens threaten each other. Thus, a solution requires that no two queens share the same row, ...
2018-11-25 09:47:20
643
原创 PAT 1067 Sort with Swap(0, i) 脚标与数组的关系 运行超时问题 燚
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 ...
2018-11-24 22:59:33
254
原创 PAT 1103 Integer Factorization (30 分)深度有限搜索,关于运行超时问题 燚
The K−P factorization of a positive integer N is to write N as the sum of the P-th power of K positive integers. You are supposed to write a program to find the K−P factorization of N for any positive...
2018-11-24 20:44:05
540
1
原创 PAT 1045 Favorite Color Stripe (30) 分动态规划 最长前缀问题 燚
Eva is trying to make her own color stripe out of a given one. She would like to keep only her favorite colors in her favorite order by cutting off those unwanted pieces and sewing the remaining parts...
2018-11-24 20:01:36
207
原创 PTA 1027 Colors in Mars (20 分)燚
People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, where the first 2 digits are for Red, the middle 2 ...
2018-11-22 21:55:43
143
原创 PAT 1035 Password (20 分)String的性质 燚
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-11-19 22:40:02
185
原创 PAT 1028 List Sorting (25 分)关于 Cin Cout 最后一个测试实例超时 燚
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-11-17 18:56:53
451
原创 PAT 1030 Travel Plan (30 分)迪杰斯特拉算法 燚
A traveler's map gives the distances between cities along the highways, together with the cost of each highway. Now you are supposed to write a program to help a traveler to decide the shortest path b...
2018-11-17 18:37:30
277
原创 PAT 1014 Waiting in Line (30 分)燚
Suppose a bank has N windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. The rules for the customers to wait in line are:The space...
2018-11-16 22:30:04
221
原创 PAT 1017 Queueing at Bank (25 分)燚
Suppose a bank has K windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. All the customers have to wait in line behind the yellow li...
2018-11-16 18:25:06
143
原创 1024 Palindromic Number (25 分)燚
1024 Palindromic Number (25 分)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...
2018-11-16 08:49:12
262
原创 PAT-1020 Tree Traversals (25 分)树的遍历
1020 Tree Traversals (25 分)Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level order ...
2018-11-15 18:38:56
337
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人