@seeplus many thanks!
1.Yes stupid question, I should have noticed better the function of the file formating with the setw and setfill. My apologies.
3. No that's ok, it is the K.first simply the subtraction of the first minimum from the first of the maximum. However, when it comes to the Div number what I actually want is to divide the 1 by only the result from the subtraction between the two firsts. Should I specify this with K? I mean K is anyway largest - smallest , but, the largest - smallest is based on the seconds comparison, not the firsts, and since I only want to subtract the firsts and not the seconds I thought the following procedure:
A]define the max and min seconds
B]get their firsts
C]subtract their firsts, and therefore when K appears it will have to do only with the firsts anyway.
As far as I understand you wrote 1 / K.first because when you wrote K you subtracted both the firsts and the seconds and created a third pair which was the result of the subtraction. Therefore since only the firsts were to be used in K you specified K.first (if I got it well?). So here comes my question:
In case I eliminate the seconds from the following:
1 2 3
|
Pairs operator-(const Pairs& p1, const Pairs& p2) {
return {p1.first - p2.first, p1.second - p2.second};
}
| |
, and the subtraction
K {largest - smallest};
is performed only to the firsts, when I reach to
div=1/K
, should I use
K.first
in this case or just
K
?
In addition, when I use only the firsts in the subtraction operator and erase the seconds it states
error E0289 --> no instance of constructor std::pair..... matches the argument list
EDIT:
1. I think I understand why you wrote it that wey with K.first and subtraction operator
2. I integrated the code to the rest of my program and compiles fine, but, it still does the same with what it did previously with my code: when it tries to open the first file "data000.txt" it terminates with the file open failure message!