#4193
Bac_Fractii
C++
În declararea de mai jos, variabilele f
și fs
memorează în câmpurile a
și b
numărătorul, respectiv numitorul câte unei fracții.
struct fractie { int a,b; } f,fs;
Fără a utiliza alte variabile, scrieți o secvență de instrucțiuni care să memoreze în variabila fs
fracția obținută prin scăderea din fracția \( \frac{2020}{2021} \) a fracției memorate în variabila f
.
Bacalaureat 2021, sesiunea august-septembrie
Problema | Bac_Fractii | Operații I/O | tastatură/ecran |
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #50209837 | Utilizator | |
Fișier | bac_fractii.cpp | Dimensiune | 23 B |
Data încărcării | 31 Martie 2024, 22:12 | Scor / rezultat | Eroare de compilare |
bac_fractii.cpp: In function 'int main()': bac_fractii.cpp:24:4: error: no match for 'operator=' (operand types are 'fractie' and 'int') fs=0; ^ bac_fractii.cpp:24:4: note: candidates are: bac_fractii.cpp:4:8: note: fractie& fractie::operator=(const fractie&) struct fractie ^ bac_fractii.cpp:4:8: note: no known conversion for argument 1 from 'int' to 'const fractie&' bac_fractii.cpp:4:8: note: fractie& fractie::operator=(fractie&&) bac_fractii.cpp:4:8: note: no known conversion for argument 1 from 'int' to 'fractie&&' bac_fractii.cpp:25:14: error: no match for 'operator-' (operand types are 'int' and 'fractie') fs+=2020/2021-f; ^ bac_fractii.cpp:25:14: 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 bac_fractii.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: bac_fractii.cpp:25:15: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int' fs+=2020/2021-f; ^ 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 bac_fractii.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: bac_fractii.cpp:25:15: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int' fs+=2020/2021-f; ^ 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 bac_fractii.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: bac_fractii.cpp:25:15: note: mismatched types 'const std::move_iterator<_Iterator>' and 'int' fs+=2020/2021-f; ^ 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 bac_fractii.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: bac_fractii.cpp:25:15: note: mismatched types 'const std::move_iterator<_Iterator>' and 'int' fs+=2020/2021-f; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Bac_Fractii 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ă.