#42
StergeElemente
C++
Scrieți definiția completă unui subprogram C++ care realizează ștergerea dintr-un tablou unidimensional dat a elementelor cu indici între două valori date.
Variante Bacalaureat 2009
Problema | StergeElemente | Operații I/O | tastatură/ecran |
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #54803541 | Utilizator | |
Fișier | stergeelemente.cpp | Dimensiune | 170 B |
Data încărcării | 09 Decembrie 2024, 10:45 | Scor / rezultat | Eroare de compilare |
stergeelemente.cpp: In function 'void sterge(int*, int, int, int)': stergeelemente.cpp:8:9: error: 'k' was not declared in this scope for(k=j+1;k<=n;k++) ^ stergeelemente.cpp:12:11: error: expected ',' before '-' token n=n-[j-i+1]; ^ stergeelemente.cpp:12:11: error: expected identifier before '-' token stergeelemente.cpp: In lambda function: stergeelemente.cpp:12:16: error: expected '{' before ';' token n=n-[j-i+1]; ^ stergeelemente.cpp: In function 'void sterge(int*, int, int, int)': stergeelemente.cpp:12:8: error: no match for 'operator-' (operand types are 'int' and 'sterge(int*, int, int, int)::__lambda0') n=n-[j-i+1]; ^ stergeelemente.cpp:12:8: note: candidates are: In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from stergeelemente.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:327:5: note: template<class _Iterator> typename std::reverse_iterator<_Iterator>::difference_type std::operator-(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&) operator-(const reverse_iterator<_Iterator>& __x, ^ /usr/include/c++/4.8/bits/stl_iterator.h:327:5: note: template argument deduction/substitution failed: stergeelemente.cpp:12:16: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int' n=n-[j-i+1]; ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from stergeelemente.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:379:5: note: template<class _IteratorL, class _IteratorR> decltype ((__y.base() - __x.base())) std::operator-(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&) operator-(const reverse_iterator<_IteratorL>& __x, ^ /usr/include/c++/4.8/bits/stl_iterator.h:379:5: note: template argument deduction/substitution failed: stergeelemente.cpp:12:16: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int' n=n-[j-i+1]; ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from stergeelemente.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:1104:5: note: template<class _IteratorL, class _IteratorR> decltype ((__x.base() - __y.base())) std::operator-(const std::move_iterator<_Iterator>&, const std::move_iterator<_IteratorR>&) operator-(const move_iterator<_IteratorL>& __x, ^ /usr/include/c++/4.8/bits/stl_iterator.h:1104:5: note: template argument deduction/substitution failed: stergeelemente.cpp:12:16: note: mismatched types 'const std::move_iterator<_Iterator>' and 'int' n=n-[j-i+1]; ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from stergeelemente.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:1111:5: note: template<class _Iterator> decltype ((__x.base() - __y.base())) std::operator-(const std::move_iterator<_Iterator>&, const std::move_iterator<_Iterator>&) operator-(const move_iterator<_Iterator>& __x, ^ /usr/include/c++/4.8/bits/stl_iterator.h:1111:5: note: template argument deduction/substitution failed: stergeelemente.cpp:12:16: note: mismatched types 'const std::move_iterator<_Iterator>' and 'int' n=n-[j-i+1]; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema StergeElemente 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ă.