![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++数据结构
Memories off
告别回忆
展开
-
The + operator of statisticians
Question: Overload the + operator to allow you to add two statisticians from the previous project. If s1 and s2 are two statisticians, then the result of s1 + s2 should be a new statistician that...原创 2019-03-19 20:32:33 · 188 阅读 · 0 评论 -
Generate pseudorandom integers
Question:In this project you will design and implement a class that can generate a sequence of pseudorandom integers, which is a sequence that appears random in many ways. The approach uses the linea...原创 2019-04-09 11:14:30 · 240 阅读 · 0 评论 -
Employee class
Question:Specify, design, and implement a class called employee. The class has data members for the employee’s name, ID number, and salary based on an hourly wage. Member functions include computing ...原创 2019-04-15 20:01:27 · 358 阅读 · 0 评论 -
Pseudorandom double number
Question:Add a new member function to the random number class of the previous project. The new member function generates the next pseudorandom member but does not return the number directly. Instead,...原创 2019-04-09 16:58:25 · 268 阅读 · 0 评论 -
Pseudorandom experiments
Question:Run some experiments to determine the distribution of numbers returned by the new pseudorandom functions from the previous project. Recall that this function returns a double number in the r...原创 2019-04-09 19:50:38 · 310 阅读 · 0 评论 -
Complex numbers
Question:Write a class for complex numbers. A complex number has the form a+bia+bia+bi, where aaa and bbb are real numbers and iii is the square root of −1-1−1. We refer to aaa as the real part and b...原创 2019-04-24 19:15:26 · 303 阅读 · 0 评论 -
Fueler class
Question:Write a class called fueler that can keep track of the fuel and mileage of a vehicle. Include private member variables to track the amount of fuel that the vehicle has consumed and the dista...原创 2019-05-06 10:44:16 · 100 阅读 · 0 评论 -
Black box
Question1:A black box test of a class is a program that tests the correctness of the class’s member functions without directly examining the private members of the class. You can imagine that the pri...原创 2019-05-08 20:08:50 · 245 阅读 · 0 评论 -
Operaters (-, -=) for bag class
Question1:Implement operators for - and -= for the bag class from Section 3.1. For two bags x and y, the bag x-y contains all the items of x, with any items from y removed. For example, suppose that ...原创 2019-05-24 20:09:55 · 199 阅读 · 0 评论 -
Sequence class
Question1:Implement the sequence class from Section 3.2. You may wish to provide some additional useful member functions, such as: (1) a function to add a new item at the front of the sequence; (2) a...原创 2019-05-27 17:21:41 · 957 阅读 · 0 评论 -
Set class
Question1:A bag can contain more than one copy of an item. For example, the chapter describes a bag that contains the number 4 and two copies of the number 8. This bag behavior is different from a se...原创 2019-05-30 17:20:41 · 262 阅读 · 0 评论 -
Subscript operator for sequence class
Question1:For a sequence x, we would like to be able to refer to the individual items using the usual C++ notation for arrays. For example, if x has three items, then we want to be able to write x[0]...原创 2019-05-29 21:28:37 · 168 阅读 · 0 评论 -
Sorted sequence class
Question1:Suppose that you implement a sequence where the value_type has a comparison operator < to determine when one item is “less than” another item. For example, integers, double numbers, and ...原创 2019-06-10 21:07:48 · 210 阅读 · 0 评论 -
Bag with receipts
Question1:In this project, you will implement a new class called a bag with receipts. This new class is similar to an ordinary bag, but the way that items are added and removed is different. Each tim...原创 2019-06-28 22:18:45 · 213 阅读 · 0 评论 -
Date class
Question:Specify, design, and implement a class called date. Use integers to represent a date’s month, day, and year. Write a member function to increment the date to the next day.Include friend fun...原创 2019-04-15 16:56:21 · 396 阅读 · 0 评论 -
Keep a bank account balanced
Question:Write a class to keep track of a balance in a bank account with a varying annual interest rate. The constructor will set both the balance and the annual interest rate to some initial values...原创 2019-04-11 20:07:45 · 199 阅读 · 0 评论 -
动态类的注意事项
如果我们的类用到了动态存储,请注意这四条规则:1)某些类成员是指针。2)成员函数按需分配和释放内存。3)重写类的自动生成的值语义(the automatic value semantics of the class),否则可能会出现两个不同的对象中的指针指向同一块动态内存的现象。这意味着必须要为这个类重写赋值操作符和拷贝构造函数。4)类要有一个析构函数(完成将动态内存返回堆的任务)...原创 2019-03-16 13:38:15 · 121 阅读 · 0 评论 -
The position of a point
Question:Specify, design, and implement a class that can be used to keep track of the position of a point in three-dimensional space. For example, consider the point drawn at the picture below. The p...原创 2019-03-20 17:19:49 · 393 阅读 · 0 评论 -
simulate a combination lock
simulate a combination lockdescriptionSpecify, design, and implement a class that can be used in a program that simulates a combination lock. The lock has a circular knob, with the numbers 0 through...原创 2019-01-06 14:37:50 · 612 阅读 · 1 评论 -
zigzag conversion
leetcodeThe string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA...原创 2018-11-23 20:13:02 · 120 阅读 · 0 评论 -
A line segment
Question:In three-dimensional space, a line segment is defined by its two endpoints. Specify, design, and implement a class for a line segment. The class should have two private member variables tha...原创 2019-03-21 20:14:40 · 329 阅读 · 0 评论 -
The Statistician Class
Question: Specify, design, and implement a class called statistician. After a statistician is initialized, it can be given a sequence of double members. Each number in the sequence is given to th...原创 2019-03-18 20:58:44 · 127 阅读 · 0 评论 -
A musical note
Question:Specify, design, and implement a class that can be used to hold information about a musical note. A programmer should be able to set and retrieve the length of the note and the value of the ...原创 2019-03-22 15:02:30 · 332 阅读 · 0 评论 -
Pseudorandom numbers in Gaussian distribution
Question:This project is a continuation of the previous project. Many applications require pseudorandom number sequences that are not uniformly distributed. For example, a program that simulates the ...原创 2019-04-10 10:21:38 · 255 阅读 · 0 评论 -
The Koenig Lookup
柯尼格查找(Koenig lookup)比如在链表实现中需要一个node局部变量,可以这样声明:main_savitch_6B::node<Item> *tail_ptr;其中main_savitch_6B是名空间,如果我们没有加using语句的话,就必须指明名空间。然而,如果我们使用节点操作函数list_copy,我们并不需要总是写成main_savitch_6B::l...原创 2019-03-27 15:05:59 · 179 阅读 · 0 评论 -
Quadratic exprssion
QuestionA one-variable quadratic expression is an arithmetic expression of the form ax2+bx+cax^2+bx+cax2+bx+c, where a, b, and c are some fixed numbers (called the coefficients) and x is a variable t...原创 2019-03-27 19:34:26 · 284 阅读 · 0 评论 -
Rational numbers
Question:Write a class for rational numbers. Each object in the class should have two integer values that define the rational number: the numerator and the denominator. For example, the fraction 5/6 ...原创 2019-04-10 20:23:37 · 442 阅读 · 0 评论 -
Simulate a lunar lander
Question:Specify, design, and implement a class that can be used to simulate a lunar lander, which is a small spaceship that transports astronauts from lunar orbit to the surface of the moon. When a ...原创 2019-04-01 21:18:14 · 427 阅读 · 0 评论 -
Real roots of a quadratic exprssion
Question:This project is a continuation of the previous project. For a quadratic expression such as ax2+bx+cax^2+bx+cax2+bx+c, a real root is any double number xxx such that ax2+bx+c=0ax^2+bx+c=0ax2+...原创 2019-03-28 21:22:13 · 232 阅读 · 0 评论 -
Keyed bag
Question1:Another way to store a collection of items is in a keyed bag. In this type of bag, whenever an item is added, the programmer using the bag also provides an integer called the key. Each item...原创 2019-07-25 20:12:29 · 136 阅读 · 0 评论