#1855
Heap
Se consideră o colecție de numere naturale, inițial vidă. Asupra ei se fac două tipuri de operații:
1 x
– valoarea x
se adaugă în colecție;2
– cea mai mare valoare din colecție se afișează, apoi se elimină din colecție.Dându-se un șir de m
operații, să se afișeze în ordine rezultatele operațiilor de tip 2
.
Problema | Heap | Operații I/O |
heap.in /heap.out
|
---|---|---|---|
Limita timp | 0.3 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #9700811 | Utilizator | |
Fișier | heap.c | Dimensiune | 1.83 KB |
Data încărcării | 23 Mai 2018, 15:34 | Scor / rezultat | Eroare de compilare |
heap.c: In function 'add': heap.c:28:5: warning: implicit declaration of function 'up' [-Wimplicit-function-declaration] up(h, pos); ^ heap.c: In function 'extract': heap.c:35:5: warning: implicit declaration of function 'down' [-Wimplicit-function-declaration] down(h, 1); ^ heap.c: At top level: heap.c:39:6: warning: conflicting types for 'down' [enabled by default] void down(Heap *h, int pos) ^ heap.c:35:5: note: previous implicit declaration of 'down' was here down(h, 1); ^ heap.c: In function 'down': heap.c:48:13: warning: implicit declaration of function 'swap' [-Wimplicit-function-declaration] swap(h->a+pos, h->a+2*pos); ^ heap.c: At top level: heap.c:60:6: warning: conflicting types for 'up' [enabled by default] void up(Heap *h, int pos) ^ heap.c:28:5: note: previous implicit declaration of 'up' was here up(h, pos); ^ heap.c:69:6: warning: conflicting types for 'swap' [enabled by default] void swap(Node *a, Node *b) ^ heap.c:48:13: note: previous implicit declaration of 'swap' was here swap(h->a+pos, h->a+2*pos); ^ heap.c: In function 'main': heap.c:84:5: error: 'for' loop initial declarations are only allowed in C99 mode for(int i=1; i<=instr; i++) ^ heap.c:84:5: note: use option -std=c99 or -std=gnu99 to compile your code heap.c:83:11: warning: ignoring return value of 'fscanf', declared with attribute warn_unused_result [-Wunused-result] fscanf(fpin, "%d", &instr); ^ heap.c:86:15: warning: ignoring return value of 'fscanf', declared with attribute warn_unused_result [-Wunused-result] fscanf(fpin, "%d", &com); ^ heap.c:88:16: warning: ignoring return value of 'fscanf', declared with attribute warn_unused_result [-Wunused-result] fscanf(fpin, "%d", &nr); ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Heap face parte din prima categorie. Soluția propusă de tine va fi evaluată astfel:
Suma punctajelor acordate pe testele utilizate pentru verificare este 100. Astfel, soluția ta poate obține cel mult 100 de puncte, caz în care se poate considera corectă.