Jul 15, 2024 at 12:17pm UTC
That seems pretty close to being right, why don't you post the whole program?
In case anyone stumbles on this nonsense, the original post / author got sh-canned.
Last edited on Aug 24, 2024 at 1:22pm UTC
Jul 15, 2024 at 12:55pm UTC
find the lowest sum of the list
You don't specify from where this list originates. Consider:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#include <iostream>
#include <sstream>
#include <limits>
struct Line {
int type;
double price;
int quant;
};
std::istream& operator >> (std::istream& is, Line& data) {
return is >> data.type >> data.price >> data.quant;
}
int main() {
std::istringstream iss {"1 12.50 2 3 10.50 1 2 7.50 3" };
auto lowSum {std::numeric_limits<double >::max()};
for (Line line; iss >> line; )
if (const auto sum { line.price * line.quant }; sum < lowSum)
lowSum = sum;
std::cout << "Lowest sum is " << lowSum << '\n' ;
}
If you also need to show the line with the lowest sum then consider:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
#include <iostream>
#include <sstream>
#include <limits>
struct Line {
int type;
double price;
int quant;
};
std::istream& operator >> (std::istream& is, Line& data) {
return is >> data.type >> data.price >> data.quant;
}
std::ostream& operator << (std::ostream& os, const Line& data) {
return os << data.type << ' ' << data.price << ' ' << data.quant;
}
int main() {
std::istringstream iss {"1 12.50 2 3 10.50 1 2 7.50 3" };
auto lowSum {std::numeric_limits<double >::max()};
Line lowLine {};
for (Line line; iss >> line; )
if (const auto sum { line.price * line.quant }; sum < lowSum) {
lowSum = sum;
lowLine = line;
}
std::cout << "Lowest sum is " << lowSum << '\n' ;
std::cout << lowLine << '\n' ;
}
Lowest sum is 10.5
3 10.5 1
Last edited on Jul 15, 2024 at 1:29pm UTC
Jul 22, 2024 at 7:47pm UTC
Wow, so the OP was etrw2, with 1 post.
Account registration was Jul 22, 2022 at 6:39am
Post datetime is Jul 15, 2024 at 8:06am
Edit datetime is Jul 18, 2024 at 4:05am
The post was edited with a spam link 3 days after being made.
Jul 22, 2024 at 11:43pm UTC
Yeah, this fooker knows the delay time so getting reported doesn't delete the post.
Jul 23, 2024 at 12:20am UTC
Incorrect, you can still delete it ;)
Jul 23, 2024 at 12:22am UTC
He's playing the long game. Two year wait!
I wonder how many other sleeper accounts exist?
Apparently new account creation has been dead for over a year.
Jul 24, 2024 at 7:52pm UTC
The account is not disabled, because only 1 post was removed.
Jul 25, 2024 at 1:13pm UTC
George, I would avoid directly hyperlinking the profile, if you don't mind, because that just indirectly links spam.
Last edited on Jul 25, 2024 at 1:13pm UTC