Code Help

Hey guys good morning or good evening or whatever :DDDD

I am doing my school work and I've ran into a problem.
I dont really know how to write the code.

8 - n ( how many lines)
3 4 10 13 ( what numbers need to be removed)The 3 means how many numbers there are.
2 2 11 (what numbers neeed to added back)The 2 means how many numbers there are.
1
3
4
7
9
10
13
14

The equation asks me to remove the numbers and add the other numbers.
The answers should be like this

Nr. 1
Nr. 3
Nr. 7
Nr. 9
Nr. 14

Nr. 1
Nr. 2
Nr. 3
Nr. 7
Nr. 9
Nr. 11
Nr. 14

I don't really know how to start and how to write it. (P.S the addding and removing have to be diff functions);
I know how to remove and add a single number but not multiple :(.
Any help or tips would be great
I dont really know how to write the code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <cctype>
#include <limits>

int main()
{
   std::cout << "Do you want someone to do all the work for you? ";
   char answer{};
   std::cin >> answer;

   std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');

   if (std::toupper(answer) == 'Y' ) { std::cout << "Post it in the Jobs section.\n"; }

   else { std::cout << "Show what you have coded so far.\n"; }

   std::cout << "Good luck.\n";
}
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>
#include <vector>
#include <set>

std::vector<int> act() {
	std::vector<int> nums;
	size_t num {};

	std::cin >> num;

	for (size_t i {}; i < num; ++i) {
		int n {};

		std::cin >> n;
		nums.push_back(n);
	}

	return nums;
}

std::multiset<int> getNums(size_t lines) {
	std::multiset<int> data;

	for (size_t i {}; i < lines; ++i) {
		int n {};

		std::cin >> n;
		data.insert(n);
	}

	return data;
}

void addnums(std::multiset<int>& s, const std::vector<int>& v) {
	for (const auto& n : v)
		s.insert(n);
}

void remnums(std::multiset<int>& s, const std::vector<int>& v) {
	for (const auto& n : v)
		s.erase(n);
}

void display(const std::multiset<int>& s) {
	for (const auto& n : s)
		std::cout << "Nr. " << n << '\n';

	std::cout << '\n';
}

int main() {
	unsigned lines {};

	std::cin >> lines;

	const auto torem {act()};
	const auto toadd {act()};
	auto data {getNums(lines)};

	remnums(data, torem);
	display(data);
	addnums(data, toadd);
	display(data);
}



8
3 4 10 13
2 2 11
1
3
4
7
9
10
13
14
Nr. 1
Nr. 3
Nr. 7
Nr. 9
Nr. 14

Nr. 1
Nr. 2
Nr. 3
Nr. 7
Nr. 9
Nr. 11
Nr. 14

Topic archived. No new replies allowed.