need some help

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
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';
}



Lowest sum is 10.5


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
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.
Yeah, this fooker knows the delay time so getting reported doesn't delete the post.
Incorrect, you can still delete it ;)
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.
Incorrect, you can still delete it ;)

I reported the tit willow twit 5 times and was still extant.

Now I see it is gone into the nether regions, the same as where its head is.
He's playing the long game. Two year wait!

There is a limit to the number of posts that can be removed by reporting before the account is disabled. Let us pray that limit was reached.
The account is not disabled, because only 1 post was removed.
The account is not disabled, because only 1 post was removed.

Maybe his first post was two years ago and that was deleted.
Then he made a post every few months, each of which were deleted.
The post count will always show as 1.
Perhaps when the "deleted post count", if it exists, reaches N, the account will be disabled.
Does anyone remember the account name? (Although that can be changed.)
This now flushed turd is not disabled.

https://cplusplus.com/user/etrw2/
George, I would avoid directly hyperlinking the profile, if you don't mind, because that just indirectly links spam.
Last edited on
Topic archived. No new replies allowed.