using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace InsertHeap
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter the number of heap: ");
int n = int.Parse(Console.ReadLine());
Heap heap = new Heap(n);
for (int i = 0; i < n; i++)
{
Console.WriteLine("Enter an item: ");
string item = Console.ReadLine();
if (item != null)
{
heap.insertItem(item);
}
else
{
i--;
}
}
for (int i = 0; i < n; i++)
{
heap.Extract_Max();
}
heap.printHeap();
}
}
}

Program

  • 1.
    using System; using System.Collections.Generic; usingSystem.Linq; using System.Text; using System.Threading.Tasks; namespace InsertHeap { class Program { static void Main(string[] args) { Console.WriteLine("Enter the number of heap: "); int n = int.Parse(Console.ReadLine()); Heap heap = new Heap(n); for (int i = 0; i < n; i++) { Console.WriteLine("Enter an item: "); string item = Console.ReadLine(); if (item != null) { heap.insertItem(item); } else { i--; } } for (int i = 0; i < n; i++) { heap.Extract_Max(); } heap.printHeap(); } } }