-
#include
using namespace std;
class money
int yuan,jiao;
public:
money(int yuan=0,int jiao=0)yuan=yuan;
jiao=jiao;
money(double d)
yuan=int(d);
jiao=int((d-yuan)*10);
money& operator++(
money operator++(int);
money& operator--(
money operator--(int);
void show(char*s)
cout<10)
yuan+=1;
jiao-=10;
return *this;
money money::operator++(int)money temp=*this;
jiao++;
if(jiao>10)
yuan+=1;
jiao-=10;
return temp;
money& money::operator--(if(jiao ==0)
yuan -=1;
jiao =10;
jiao--;
return *this;
money money::operator--(int)money temp=*this;
if(jiao ==0)
yuan -=1;
jiao =10;
jiao --
return temp;
Here you have an example, I think you have to figure out 2 questions.
1.Function overloading.
2.The reason why the value returned by the pre++ is different from the post++.
-
You declare yes inside the class.
money operator++(
The implementation is. money &money::operator++ returns a different type, so there was an error.
The function is the same as above.
-
To give an idea, first of all, make it clear that for a certain number, you can either choose to move the number to the head of the queue or not move it, and each number can only move at most once. A number that needs to be moved can only be preceded by that numberThere are numbers that are greater than him, or there may be numbers that are larger than him. If there is a number that is larger than him in front of this number, then the movement is definitely necessary, and if there is no number larger than him in front of this number, but there is a number larger than him that will move, then the movement is still necessary.
The first case is easy to judge, and in the second case, it is enough to determine whether all the numbers that are larger than this number are arranged from small to large.
-
There are several important points in this question:
1. It can be read in a loop until 0 is entered.
2. Keep integers greater than 0 and divisible by 4. This one is also easy to deal with.
3. Sort from small to large, this is no problem. There are a whole bunch of sorting algorithms that can be found online.
4. There are 800 million input data. This is very crucial. Because memory can't allocate 800 million integers all at once, waiting to be put in data.
This one has to be broken into chunks. For example, apply for an array of 1024 * 1024 integers to store the filtered data. When the mold is full, sort it.
Then write to the disk file. Then use this array again, and after it is full again, the sharp age sorts the silver in the open, and writes it to the file.
5. Finally, use merge and sort to read the data out of the file piece by piece. After sorting, output to the screen.
The output of this program is: 4
You can standardize the program to make it easier to understand. >>>More
First of all, a Class C has 254 addresses but there is always one as a gateway route, so there can be a maximum of 253 hosts. Then these hosts are public IP addresses. It can be done by setting up a LAN and using one IP. >>>More
It's simple: you can't write it in C++, I write it in C.
**As follows. #include "" >>>More
Because your temporary files are stored in C: Documents and Settings Administrator Local Settings Temp >>>More
Operate from right to left, -i--so calculate -i first--, the operation level is higher, so it can be written as -(i--)i--for 8, add a - sign, so -i--is 8, at this time i--after, i=7, and then -i++ is the same, can be written as -(i++) so -i++ is -7, at this time i++ becomes 8,--i, subtract 1 before execution, so --i is 7, at this time i=7, ++i is the same, add 1 before executing i, so ++i is 8, at this time i=8, then calculate i--,i--is still equal to 8, then i minus one becomes 7, i++, i++ is equal to 7, and then i++, i=8, so finally i=8, and then print it out in turn, pay attention to the operation is from right to left, but print from left to right print i,i++,i--,i,--i,-i++,i-, so the check mark result is out.