pls i want an answer today thank you

Given a txt file named Heap.txt in which it is
stored 14 integers that have the minimum layout
heap. You should read this file and get it
save to a table of 100 (integer) elements. From
the keyboard will be asked for a value (integer) which should
is added at the end of the table (after the data read). In
then you need to call the HeapifyUp function (which will
implement) to place the new item in the new location
where the pile property will not be violated. The program as an output
will return-print the new location of the item
you entered the table and the table.do you know the code pls help me
 
  
What have you done so far? Show us your code, and we'll help you fix any problems you have.
Hello mikedpj,

The answer is 42! https://www.youtube.com/watch?v=aboZctrHfK8

Furry Guy wrote:
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";
}


Here's the code, or close enough, right?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <fstream>
#include <iterator>
#include <iostream>
#include <algorithm>
#include <vector>

int main()
{
  std::vector<int> heap;

  if (std::ifstream fin{ "heap.txt" }) 
    std::copy(std::istream_iterator<int>{fin}, {}, std::back_inserter(heap));

  std::make_heap(heap.begin(), heap.end()); 
  std::copy(heap.begin(), heap.end(), std::ostream_iterator<int>(std::cout, " ")); 
}

Topic archived. No new replies allowed.