#4706
Scrieţi definiția completă a subprogramului C++ Peak cu antetul:
void Peak(int a[], int n, int &isPeak, int &poz)
unde a este un tablou unidimensional cu maximum 1000 de numere întregi, n, numărul efectiv de elemente ale tabloului. Dacă vectorul a memorează un șir peak, atunci isPeak va fi egal cu 1, iar poz va reține poziția numărului maxim din a. Dacă vectorul a nu este un șir peak, atunci isPeak va fi egal cu 0, iar poz va reține valoarea 0.
| Problema | Peak | Operații I/O |
peak.in/peak.out
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64120944 | Utilizator | |
| Fișier | peak.cpp | Dimensiune | 672 B |
| Data încărcării | 18 Aprilie 2026, 13:53 | Scor/rezultat | Eroare de compilare |
peak.cpp:7:33: error: expected ‘,’ or ‘...’ before ‘isPeak’ 7 | void Peak(int a[], int n, int[] isPeak, int[] poz) { | ^~~~~~ peak.cpp: In function ‘void Peak(int*, int, int*)’: peak.cpp:19:9: error: ‘isPeak’ was not declared in this scope; did you mean ‘Peak’? 19 | isPeak[0] = 0; | ^~~~~~ | Peak peak.cpp:20:9: error: ‘poz’ was not declared in this scope 20 | poz[0] = 0; | ^~~ peak.cpp:33:9: error: ‘isPeak’ was not declared in this scope; did you mean ‘Peak’? 33 | isPeak[0] = 1; | ^~~~~~ | Peak peak.cpp:34:9: error: ‘poz’ was not declared in this scope 34 | poz[0] = peakPos; | ^~~ peak.cpp:36:9: error: ‘isPeak’ was not declared in this scope; did you mean ‘Peak’? 36 | isPeak[0] = 0; | ^~~~~~ | Peak peak.cpp:37:9: error: ‘poz’ was not declared in this scope 37 | poz[0] = 0; | ^~~ peak.cpp: In function ‘int main()’: peak.cpp:46:16: error: invalid conversion from ‘int’ to ‘int*’ [-fpermissive] 46 | Peak(a, n, isPeak, poz); | ^~~~~~ | | | int peak.cpp:46:9: error: too many arguments to function ‘void Peak(int*, int, int*)’ 46 | Peak(a, n, isPeak, poz); | ~~~~^~~~~~~~~~~~~~~~~~~ peak.cpp:7:6: note: declared here 7 | void Peak(int a[], int n, int[] isPeak, int[] poz) { | ^~~~
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Peak face parte din a doua categorie. Pentru aceste probleme se folosește un program suport, furnizat de propunătorul problemei. 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ă.