#3536
Se consideră o expresie aritmetică formată din numere naturale și operatorii binari + (adunare), - (scădere), * (înmulțire), ^ (ridicare la putere). Să se determine forma postfixată corespunzătoare și să se calculeze valoarea expresiei.
| Problema | EvaluareExpresie | Operații I/O |
evaluareexpresie.in/evaluareexpresie.out
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 16 MB
/
Stivă 8 MB
|
| Id soluție | #61866748 | Utilizator | |
| Fișier | evaluareexpresie.cpp | Dimensiune | 2.71 KB |
| Data încărcării | 12 Decembrie 2025, 19:35 | Scor/rezultat | Eroare de compilare |
evaluareexpresie.cpp:13:103: error: 'any' was not declared in this scope void clearOperation(stack<int8_t>& op, stack<bool>& sgn, stack<int64_t>& val, const int8_t& p, vector<any>& v) ^ evaluareexpresie.cpp:13:106: error: template argument 1 is invalid void clearOperation(stack<int8_t>& op, stack<bool>& sgn, stack<int64_t>& val, const int8_t& p, vector<any>& v) ^ evaluareexpresie.cpp:13:106: error: template argument 2 is invalid evaluareexpresie.cpp: In function 'void clearOperation(std::stack<signed char>&, std::stack<bool>&, std::stack<long long int>&, const int8_t&, int&)': evaluareexpresie.cpp:18:25: error: request for member 'push_back' in 'v', which is of non-class type 'int' if(sgn.top()) v.push_back('-'); ^ evaluareexpresie.cpp:19:16: error: request for member 'push_back' in 'v', which is of non-class type 'int' else v.push_back(nrToCh[op.top()]); ^ evaluareexpresie.cpp: At global scope: evaluareexpresie.cpp:42:8: error: 'any' was not declared in this scope vector<any> poloneza(const string& s) ^ evaluareexpresie.cpp:42:11: error: template argument 1 is invalid vector<any> poloneza(const string& s) ^ evaluareexpresie.cpp:42:11: error: template argument 2 is invalid evaluareexpresie.cpp: In function 'int poloneza(const string&)': evaluareexpresie.cpp:44:12: error: 'any' was not declared in this scope vector<any> v; ^ evaluareexpresie.cpp:44:15: error: template argument 1 is invalid vector<any> v; ^ evaluareexpresie.cpp:44:15: error: template argument 2 is invalid evaluareexpresie.cpp:44:18: error: invalid type in declaration before ';' token vector<any> v; ^ evaluareexpresie.cpp:76:15: error: request for member 'push_back' in 'v', which is of non-class type 'int' v.push_back(x); ^ evaluareexpresie.cpp:81:7: error: request for member 'push_back' in 'v', which is of non-class type 'int' v.push_back(x); ^ evaluareexpresie.cpp: At global scope: evaluareexpresie.cpp:94:56: error: template argument 2 is invalid unordered_map<type_index, void(*)(any const&, ostream&)> streamers; ^ evaluareexpresie.cpp:94:56: error: template argument 5 is invalid evaluareexpresie.cpp:94:67: error: invalid type in declaration before ';' token unordered_map<type_index, void(*)(any const&, ostream&)> streamers; ^ evaluareexpresie.cpp: In function 'void add_streamer()': evaluareexpresie.cpp:99:14: error: no match for 'operator[]' (operand types are 'int' and 'const std::type_info') streamers[typeid(T)] = [](any const& a, ostream& os) ^ evaluareexpresie.cpp:99:31: error: 'any' has not been declared streamers[typeid(T)] = [](any const& a, ostream& os) ^ evaluareexpresie.cpp: In lambda function: evaluareexpresie.cpp:101:15: error: 'any_cast' was not declared in this scope os << any_cast<T>(a); ^ evaluareexpresie.cpp:101:25: error: expected primary-expression before '>' token os << any_cast<T>(a); ^ evaluareexpresie.cpp: In function 'void add_streamers()': evaluareexpresie.cpp:107:31: error: expected primary-expression before '...' token (void(add_streamer<T>()), ... ); ^ evaluareexpresie.cpp:107:31: error: expected ')' before '...' token evaluareexpresie.cpp: At global scope: evaluareexpresie.cpp:110:26: error: 'any' has not been declared void stream(ostream& os, any const& a) ^ evaluareexpresie.cpp: In function 'void stream(std::ostream&, const int&)': evaluareexpresie.cpp:112:17: error: request for member 'type' in 'a', which is of non-class type 'const int' streamers[a.type()](a, os); ^ evaluareexpresie.cpp: At global scope: evaluareexpresie.cpp:115:25: error: 'any' was not declared in this scope void write(const vector<any>& v) ^ evaluareexpresie.cpp:115:28: error: template argument 1 is invalid void write(const vector<any>& v) ^ evaluareexpresie.cpp:115:28: error: template argument 2 is invalid evaluareexpresie.cpp: In function 'void write(const int&)': evaluareexpresie.cpp:117:17: error: no matching function for call to 'begin(const int&)' for(auto f: v) ^ evaluareexpresie.cpp:117:17: note: candidates are: In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:94:0, from evaluareexpresie.cpp:2: /usr/include/c++/4.8/valarray:1206:5: note: template<class _Tp> const _Tp* std::begin(const std::valarray<_Tp>&) begin(const valarray<_Tp>& __va) ^ /usr/include/c++/4.8/valarray:1206:5: note: template argument deduction/substitution failed: evaluareexpresie.cpp:117:17: note: mismatched types 'const std::valarray<_Tp>' and 'const int' for(auto f: v) ^ In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:94:0, from evaluareexpresie.cpp:2: /usr/include/c++/4.8/valarray:1196:5: note: template<class _Tp> _Tp* std::begin(std::valarray<_Tp>&) begin(valarray<_Tp>& __va) ^ /usr/include/c++/4.8/valarray:1196:5: note: template argument deduction/substitution failed: evaluareexpresie.cpp:117:17: note: mismatched types 'std::valarray<_Tp>' and 'const int' for(auto f: v) ^ In file included from /usr/include/c++/4.8/bits/basic_string.h:42:0, from /usr/include/c++/4.8/string:52, 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/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from evaluareexpresie.cpp:2: /usr/include/c++/4.8/initializer_list:89:5: note: template<class _Tp> constexpr const _Tp* std::begin(std::initializer_list<_Tp>) begin(initializer_list<_Tp> __ils) noexcept ^ /usr/include/c++/4.8/initializer_list:89:5: note: template argument deduction/substitution failed: evaluareexpresie.cpp:117:17: note: mismatched types 'std::initializer_list<_Tp>' and 'int' for(auto f: v) ^ In file included from /usr/include/c++/4.8/string:51: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/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from evaluareexpresie.cpp:2: /usr/include/c++/4.8/bits/range_access.h:87:5: note: template<class _Tp, unsigned int _Nm> _Tp* std::begin(_Tp (&)[_Nm]) begin(_Tp (&__arr)[_Nm]) ^ /usr/include/c++/4.8/bits/range_access.h:87:5: note: template argument deduction/substitution failed: evaluareexpresie.cpp:117:17: note: mismatched types '_Tp [_Nm]' and 'const int' for(auto f: v) ^ In file included from /usr/include/c++/4.8/string:51: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/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from evaluareexpresie.cpp:2: /usr/include/c++/4.8/bits/range_access.h:58:5: note: template<class _Container> decltype (__cont.begin()) std::begin(const _Container&) begin(const _Container& __cont) -> decltype(__cont.begin()) ^ /usr/include/c++/4.8/bits/range_access.h:58:5: note: template argument deduction/substitution failed: /usr/include/c++/4.8/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.begin()) std::begin(const _Container&) [with _Container = int]': evaluareexpresie.cpp:117:17: required from here /usr/include/c++/4.8/bits/range_access.h:58:5: error: request for member 'begin' in '__cont', which is of non-class type 'const int' /usr/include/c++/4.8/bits/range_access.h:48:5: note: template<class _Container> decltype (__cont.begin()) std::begin(_Container&) begin(_Container& __cont) -> decltype(__cont.begin()) ^ /usr/include/c++/4.8/bits/range_access.h:48:5: note: template argument deduction/substitution failed: /usr/include/c++/4.8/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.begin()) std::begin(_Container&) [with _Container = const int]': evaluareexpresie.cpp:117:17: required from here /usr/include/c++/4.8/bits/range_access.h:48:5: error: request for member 'begin' in '__cont', which is of non-class type 'const int' evaluareexpresie.cpp:117:17: error: no matching function for call to 'end(const int&)' for(auto f: v) ^ evaluareexpresie.cpp:117:17: note: candidates are: In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:94:0, from evaluareexpresie.cpp:2: /usr/include/c++/4.8/valarray:1226:5: note: template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&) end(const valarray<_Tp>& __va) ^ /usr/include/c++/4.8/valarray:1226:5: note: template argument deduction/substitution failed: evaluareexpresie.cpp:117:17: note: mismatched types 'const std::valarray<_Tp>' and 'const int' for(auto f: v) ^ In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:94:0, from evaluareexpresie.cpp:2: /usr/include/c++/4.8/valarray:1216:5: note: template<class _Tp> _Tp* std::end(std::valarray<_Tp>&) end(valarray<_Tp>& __va) ^ /usr/include/c++/4.8/valarray:1216:5: note: template argument deduction/substitution failed: evaluareexpresie.cpp:117:17: note: mismatched types 'std::valarray<_Tp>' and 'const int' for(auto f: v) ^ In file included from /usr/include/c++/4.8/bits/basic_string.h:42:0, from /usr/include/c++/4.8/string:52, 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/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from evaluareexpresie.cpp:2: /usr/include/c++/4.8/initializer_list:99:5: note: template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>) end(initializer_list<_Tp> __ils) noexcept ^ /usr/include/c++/4.8/initializer_list:99:5: note: template argument deduction/substitution failed: evaluareexpresie.cpp:117:17: note: mismatched types 'std::initializer_list<_Tp>' and 'int' for(auto f: v) ^ In file included from /usr/include/c++/4.8/string:51: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/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from evaluareexpresie.cpp:2: /usr/include/c++/4.8/bits/range_access.h:97:5: note: template<class _Tp, unsigned int _Nm> _Tp* std::end(_Tp (&)[_Nm]) end(_Tp (&__arr)[_Nm]) ^ /usr/include/c++/4.8/bits/range_access.h:97:5: note: template argument deduction/substitution failed: evaluareexpresie.cpp:117:17: note: mismatched types '_Tp [_Nm]' and 'const int' for(auto f: v) ^ In file included from /usr/include/c++/4.8/string:51: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/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from evaluareexpresie.cpp:2: /usr/include/c++/4.8/bits/range_access.h:78:5: note: template<class _Container> decltype (__cont.end()) std::end(const _Container&) end(const _Container& __cont) -> decltype(__cont.end()) ^ /usr/include/c++/4.8/bits/range_access.h:78:5: note: template argument deduction/substitution failed: /usr/include/c++/4.8/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.end()) std::end(const _Container&) [with _Container = int]': evaluareexpresie.cpp:117:17: required from here /usr/include/c++/4.8/bits/range_access.h:78:5: error: request for member 'end' in '__cont', which is of non-class type 'const int' /usr/include/c++/4.8/bits/range_access.h:68:5: note: template<class _Container> decltype (__cont.end()) std::end(_Container&) end(_Container& __cont) -> decltype(__cont.end()) ^ /usr/include/c++/4.8/bits/range_access.h:68:5: note: template argument deduction/substitution failed: /usr/include/c++/4.8/bits/range_access.h: In substitution of 'template<class _Container> decltype (__cont.end()) std::end(_Container&) [with _Container = const int]': evaluareexpresie.cpp:117:17: required from here /usr/include/c++/4.8/bits/range_access.h:68:5: error: request for member 'end' in '__cont', which is of non-class type 'const int'
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema EvaluareExpresie 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ă.