Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.cpp
- // qwerty
- //
- // Created by Святой Отец on 11.09.17.
- // Copyright © 2017 Святой Отец. All rights reserved.
- //
- #include <fstream>
- #include <iostream>
- #include <cmath>
- using namespace std;
- bool IsHeap=true;
- int lenght=NULL;
- void hueta(int* heap,int index){
- if(IsHeap){
- if(2*index+1<lenght)
- if(heap[index]>=heap[2*index+1])
- IsHeap=false;
- else
- hueta(heap,2*index+1);
- else;
- if(2*index+2<lenght)
- if(heap[index]>=heap[2*index+2])
- IsHeap=false;
- else
- hueta(heap,2*index+2);
- else;
- }
- }
- int main(int argc, const char * argv[]) {
- ifstream fin("/Users/i9788365/Desktop/qwerty/qwerty/1.rtf");
- fin>>lenght;
- int * heap = (int*) malloc(lenght + 1);
- for(int i=0;i<lenght;i++)
- cin>>heap[i];
- int a;
- fin>>a;
- cout<<a<<lenght;
- fin.close();
- ofstream fout("isheap.out");
- hueta(heap,0);
- cout<<(IsHeap?"YES":"NO");
- fout.close();
- free(heap);
- }
Advertisement
Add Comment
Please, Sign In to add comment