C++代写-CS240
时间:2022-10-25
University of Waterloo
CS240 - Fall 2022
Programming Question 1
Due Date: Wednesday October 26 at 5pm
Please read https://student.cs.uwaterloo.ca/~cs240/f22/assignments.phtml#guidelines
for guidelines on submission. Submit your solution electronically on Marmoset as described
below.
There are 6 possible marks available.
Problem 1 [6 marks]
Implement your algorithm from Assignment 2, Problem 5 using C++ and compiled using
g++ -std=c++17 in the linux.student.cs.uwaterloo.ca environment. Please note that imple-
mentations that are not in O(1 + k) will not receive full marks.
Your program should read from cin the size n, then the n integers in the heap A[0 . . . n−1],
and finally the integer c, and then write to cout the integers in the heap that are greater
than or equal to c. You may assume that every integer in the input is at least 0 and at most
231 − 1 (so that every integer will fit into a variable of type int).
Every integer in the input and output should be on a separate line. So for instance if the
input consists of the following lines:
5
17
15
13
10
3
12
then your program should print out the integers 17, 15, and 13 in any order (and on separate
lines). Note, ‘5’ represents n, so the next 5 numbers ‘17, 15, 13, 10, 3’ represent what goes
in the heap, and ‘12’ represents c.
Submit the code for your main function, along with any helper functions, in a file called
report.cpp.
1
essay、essay代写