際際滷

際際滷Share a Scribd company logo
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();
}
}
}

More Related Content

What's hot (7)

Media12132
Media12132Media12132
Media12132
htmrk
Reactive x
Reactive xReactive x
Reactive x
myposter GmbH
Suma factoriales impares
Suma factoriales imparesSuma factoriales impares
Suma factoriales impares
iruy ub
Recursion prog (1)
Recursion prog (1)Recursion prog (1)
Recursion prog (1)
Frijo Francis

Viewers also liked (13)

Guia tp4 3 bocas anguloGuia tp4 3 bocas angulo
Guia tp4 3 bocas angulo
MARCOS ANGER
爨爨鉦Δ爭爭 爨爨逗Χ爭爨爨爨逗Ζ爭爨爨鉦Σ爭爭爨 爨爨鉦爨爨む爨
爨爨鉦Δ爭爭 爨爨逗Χ爭爨爨爨逗Ζ爭爨爨鉦Σ爭爭爨 爨爨鉦爨爨む爨爨爨鉦Δ爭爭 爨爨逗Χ爭爨爨爨逗Ζ爭爨爨鉦Σ爭爭爨 爨爨鉦爨爨む爨
爨爨鉦Δ爭爭 爨爨逗Χ爭爨爨爨逗Ζ爭爨爨鉦Σ爭爭爨 爨爨鉦爨爨む爨
zulhash uddin
Full Resume
Full ResumeFull Resume
Full Resume
Avery Karkosh
Tema 3 diversidade h鱈drica e bioxeogr叩fica
Tema 3 diversidade h鱈drica e bioxeogr叩ficaTema 3 diversidade h鱈drica e bioxeogr叩fica
Tema 3 diversidade h鱈drica e bioxeogr叩fica
velazquezturnesnieves
Juke box circus 2013Juke box circus 2013
Juke box circus 2013
Ecr Roanne
List building essentials
List building essentialsList building essentials
List building essentials
Independent
S3c3 chapter 3-people and techniques used by the giant to give trouble to the...
S3c3 chapter 3-people and techniques used by the giant to give trouble to the...S3c3 chapter 3-people and techniques used by the giant to give trouble to the...
S3c3 chapter 3-people and techniques used by the giant to give trouble to the...
Shivu P
Best Clog Sandals
Best Clog SandalsBest Clog Sandals
Best Clog Sandals
troentorpsclog12
How to Improve Purchase Intent, Website Conversion and SEO
How to Improve Purchase Intent, Website Conversion and SEOHow to Improve Purchase Intent, Website Conversion and SEO
How to Improve Purchase Intent, Website Conversion and SEO
Leonardo
Project List Bacolod GGTC Humanus Philippines, Africa, Fiji
Project List Bacolod GGTC Humanus Philippines, Africa, FijiProject List Bacolod GGTC Humanus Philippines, Africa, Fiji
Project List Bacolod GGTC Humanus Philippines, Africa, Fiji
Eduardo Bacolod
Pawe Pluta
Pawe PlutaPawe Pluta
Pawe Pluta
Pawe Pluta
Ultimate guide: How to use Hootsuite to broadcast single message across multi...
Ultimate guide: How to use Hootsuite to broadcast single message across multi...Ultimate guide: How to use Hootsuite to broadcast single message across multi...
Ultimate guide: How to use Hootsuite to broadcast single message across multi...
Ailyn Arcangeles
How To Use If This Then That
How To Use If This Then ThatHow To Use If This Then That
How To Use If This Then That
Ailyn Arcangeles
Guia tp4 3 bocas anguloGuia tp4 3 bocas angulo
Guia tp4 3 bocas angulo
MARCOS ANGER
爨爨鉦Δ爭爭 爨爨逗Χ爭爨爨爨逗Ζ爭爨爨鉦Σ爭爭爨 爨爨鉦爨爨む爨
爨爨鉦Δ爭爭 爨爨逗Χ爭爨爨爨逗Ζ爭爨爨鉦Σ爭爭爨 爨爨鉦爨爨む爨爨爨鉦Δ爭爭 爨爨逗Χ爭爨爨爨逗Ζ爭爨爨鉦Σ爭爭爨 爨爨鉦爨爨む爨
爨爨鉦Δ爭爭 爨爨逗Χ爭爨爨爨逗Ζ爭爨爨鉦Σ爭爭爨 爨爨鉦爨爨む爨
zulhash uddin
Tema 3 diversidade h鱈drica e bioxeogr叩fica
Tema 3 diversidade h鱈drica e bioxeogr叩ficaTema 3 diversidade h鱈drica e bioxeogr叩fica
Tema 3 diversidade h鱈drica e bioxeogr叩fica
velazquezturnesnieves
Juke box circus 2013Juke box circus 2013
Juke box circus 2013
Ecr Roanne
List building essentials
List building essentialsList building essentials
List building essentials
Independent
S3c3 chapter 3-people and techniques used by the giant to give trouble to the...
S3c3 chapter 3-people and techniques used by the giant to give trouble to the...S3c3 chapter 3-people and techniques used by the giant to give trouble to the...
S3c3 chapter 3-people and techniques used by the giant to give trouble to the...
Shivu P
How to Improve Purchase Intent, Website Conversion and SEO
How to Improve Purchase Intent, Website Conversion and SEOHow to Improve Purchase Intent, Website Conversion and SEO
How to Improve Purchase Intent, Website Conversion and SEO
Leonardo
Project List Bacolod GGTC Humanus Philippines, Africa, Fiji
Project List Bacolod GGTC Humanus Philippines, Africa, FijiProject List Bacolod GGTC Humanus Philippines, Africa, Fiji
Project List Bacolod GGTC Humanus Philippines, Africa, Fiji
Eduardo Bacolod
Ultimate guide: How to use Hootsuite to broadcast single message across multi...
Ultimate guide: How to use Hootsuite to broadcast single message across multi...Ultimate guide: How to use Hootsuite to broadcast single message across multi...
Ultimate guide: How to use Hootsuite to broadcast single message across multi...
Ailyn Arcangeles
How To Use If This Then That
How To Use If This Then ThatHow To Use If This Then That
How To Use If This Then That
Ailyn Arcangeles

Program

  • 1. 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(); } } }