#4704
MajorImpar
C++
Subprogramul majImp
are doi parametri, a
și b
, prin care primește câte un număr natural (2 ≤ a ≤ b ≤ 10.000
). Subprogramul returnează cel mai mic număr major impar din intervalul [a,b]
, sau valoarea 0
, dacă în interval nu există un astfel de număr. Scrieţi în C/C++ definiţia completă a subprogramului.
Bac 2024, sesiunea iunie-iulie
Problema | MajorImpar | Operații I/O |
majimp.in /majimp.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 2 MB
/
Stivă 1 MB
|
Id soluție | #53041476 | Utilizator | |
Fișier | majorimpar.cpp | Dimensiune | 403 B |
Data încărcării | 16 Octombrie 2024, 11:26 | Scor / rezultat | Eroare de compilare |
majorimpar.cpp:14:9: error: stray '\316' in program int Δp,Δi,d; ^ majorimpar.cpp:14:9: error: stray '\224' in program majorimpar.cpp:14:9: error: stray '\316' in program majorimpar.cpp:14:9: error: stray '\224' in program majorimpar.cpp:18:13: error: stray '\316' in program Δp=Δp+d; ^ majorimpar.cpp:18:13: error: stray '\224' in program majorimpar.cpp:18:13: error: stray '\316' in program majorimpar.cpp:18:13: error: stray '\224' in program majorimpar.cpp:20:13: error: stray '\316' in program Δi=Δi+d; ^ majorimpar.cpp:20:13: error: stray '\224' in program majorimpar.cpp:20:13: error: stray '\316' in program majorimpar.cpp:20:13: error: stray '\224' in program majorimpar.cpp:21:13: error: stray '\316' in program if(Δi>Δp) ^ majorimpar.cpp:21:13: error: stray '\224' in program majorimpar.cpp:21:13: error: stray '\316' in program majorimpar.cpp:21:13: error: stray '\224' in program majorimpar.cpp: In function 'int majImp(int, int)': majorimpar.cpp:14:19: error: redeclaration of 'int i' int Δp,Δi,d; ^ majorimpar.cpp:12:13: error: 'int i' previously declared here for(int i=a;i<=b;i++) ^ majorimpar.cpp:16:15: warning: suggest explicit braces to avoid ambiguous 'else' [-Wparentheses] if(i%d==0) ^ majorimpar.cpp:22:9: error: expected primary-expression before '}' token } ^ majorimpar.cpp:22:9: error: expected ';' before '}' token majorimpar.cpp:23:16: error: 'i' was not declared in this scope return i; ^ majorimpar.cpp: In function 'int main()': majorimpar.cpp:29:7: error: no match for 'operator<' (operand types are 'std::ostream {aka std::basic_ostream<char>}' and 'int') cout<majImp(a,b) ^ majorimpar.cpp:29:7: note: candidates are: In file included from /usr/include/c++/4.8/bits/stl_algobase.h:64: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/istream:38, from /usr/include/c++/4.8/fstream:38, from majorimpar.cpp:1: /usr/include/c++/4.8/bits/stl_pair.h:220:5: note: template<class _T1, class _T2> constexpr bool std::operator<(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&) operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) ^ /usr/include/c++/4.8/bits/stl_pair.h:220:5: note: template argument deduction/substitution failed: majorimpar.cpp:29:18: note: 'std::ostream {aka std::basic_ostream<char>}' is not derived from 'const std::pair<_T1, _T2>' cout<majImp(a,b) ^ 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/istream:38, from /usr/include/c++/4.8/fstream:38, from majorimpar.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:297:5: note: template<class _Iterator> bool 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:297:5: note: template argument deduction/substitution failed: majorimpar.cpp:29:18: note: 'std::ostream {aka std::basic_ostream<char>}' is not derived from 'const std::reverse_iterator<_Iterator>' cout<majImp(a,b) ^ 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/istream:38, from /usr/include/c++/4.8/fstream:38, from majorimpar.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:347:5: note: template<class _IteratorL, class _IteratorR> bool 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:347:5: note: template argument deduction/substitution failed: majorimpar.cpp:29:18: note: 'std::ostream {aka std::basic_ostream<char>}' is not derived from 'const std::reverse_iterator<_Iterator>' cout<majImp(a,b) ^ 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/istream:38, from /usr/include/c++/4.8/fstream:38, from majorimpar.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:1055:5: note: template<class _IteratorL, class _IteratorR> bool 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:1055:5: note: template argument deduction/substitution failed: majorimpar.cpp:29:18: note: 'std::ostream {aka std::basic_ostream<char>}' is not derived from 'const std::move_iterator<_Iterator>' cout<majImp(a,b) ^ 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/istream:38, from /usr/include/c++/4.8/fstream:38, from majorimpar.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:1061:5: note: template<class _Iterator> bool 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:1061:5: note: template argument deduction/substitution failed: majorimpar.cpp:29:18: note: 'std::ostream {aka std::basic_ostream<char>}' is not derived from 'const std::move_iterator<_Iterator>' cout<majImp(a,b) ^ In file included from /usr/include/c++/4.8/string:52:0, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/fstream:38, from majorimpar.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:2569:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&) operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, ^ /usr/include/c++/4.8/bits/basic_string.h:2569:5: note: template argument deduction/substitution failed: majorimpar.cpp:29:18: note: 'std::ostream {aka std::basic_ostream<char>}' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>' cout<majImp(a,b) ^ In file included from /usr/include/c++/4.8/string:52:0, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/fstream:38, from majorimpar.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:2581:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*) operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, ^ /usr/include/c++/4.8/bits/basic_string.h:2581:5: note: template argument deduction/substitution failed: majorimpar.cpp:29:18: note: 'std::ostream {aka std::basic_ostream<char>}' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>' cout<majImp(a,b) ^ In file included from /usr/include/c++/4.8/string:52:0, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/fstream:38, from majorimpar.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:2593:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&) operator<(const _CharT* __lhs, ^ /usr/include/c++/4.8/bits/basic_string.h:2593:5: note: template argument deduction/substitution failed: majorimpar.cpp:29:18: note: mismatched types 'const _CharT*' and 'std::basic_ostream<char>' cout<majImp(a,b) ^ majorimpar.cpp:30:5: error: expected ';' before 'return' return 0; ^ majorimpar.cpp: In function 'int main()': majorimpar.cpp:33:5: error: redefinition of 'int main()' int main() ^ majorimpar.cpp:25:5: error: 'int main()' previously defined here int main() ^ majorimpar.cpp: In function 'int majImp(int, int)': majorimpar.cpp:24:1: warning: control reaches end of non-void function [-Wreturn-type] } ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema MajorImpar 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ă.