need some help

Jul 15, 2024 at 12:17pm
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
Jul 15, 2024 at 12:55pm
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 Jul 15, 2024 at 1:29pm
Jul 22, 2024 at 7:47pm
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
Yeah, this fooker knows the delay time so getting reported doesn't delete the post.
Jul 23, 2024 at 12:20am
Incorrect, you can still delete it ;)
Jul 23, 2024 at 12:22am
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 23, 2024 at 4:14am
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.
Jul 23, 2024 at 4:16am
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.
Jul 24, 2024 at 7:52pm
The account is not disabled, because only 1 post was removed.
Jul 24, 2024 at 8:01pm
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.)
Jul 25, 2024 at 2:52am
This now flushed turd is not disabled.

https://cplusplus.com/user/etrw2/
Jul 25, 2024 at 1:13pm
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
Topic archived. No new replies allowed.