#3720
Aproape
Se dă un număr N
în baza 10
. Un număr M
se numește aproape de N
dacă îndeplinește următoarele trei condiții:
N
.10
diferă față de cea a lui N
în exact o poziție. Altfel spus, nu mai mult, nici mai puțin, o singură cifră diferă.1
mai mică, fie cu 1
mai mare decât cifra corespunzătoare din N
.Cunoscând numărul N
, să se scrie un program care determină:
N
.N
.OJI 2021, clasa a IX-a
Problema | Aproape | Operații I/O |
aproape.in /aproape.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 32 MB
/
Stivă 8 MB
|
Id soluție | #35475514 | Utilizator | |
Fișier | aproape.cpp | Dimensiune | 1.61 KB |
Data încărcării | 10 Martie 2022, 16:38 | Scor / rezultat | Eroare de compilare |
aproape.cpp: In function 'bool isNum(const string&)': aproape.cpp:23:76: error: parameter declared 'auto' return s.front() != '0' && std::all_of(s.begin(), s.end(), [](auto c){ return c >= '0' && c <= '9'; }); ^ aproape.cpp: In lambda function: aproape.cpp:23:87: error: 'c' was not declared in this scope return s.front() != '0' && std::all_of(s.begin(), s.end(), [](auto c){ return c >= '0' && c <= '9'; }); ^ aproape.cpp: In function 'int main()': aproape.cpp:58:41: error: use of deleted function 'std::basic_ifstream<char>::basic_ifstream(const std::basic_ifstream<char>&)' auto in = std::ifstream("aproape.in"); ^ In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:69:0, from aproape.cpp:1: /usr/include/c++/4.8/fstream:427:11: note: 'std::basic_ifstream<char>::basic_ifstream(const std::basic_ifstream<char>&)' is implicitly deleted because the default definition would be ill-formed: class basic_ifstream : public basic_istream<_CharT, _Traits> ^ /usr/include/c++/4.8/fstream:427:11: error: use of deleted function 'std::basic_istream<char>::basic_istream(const std::basic_istream<char>&)' In file included from /usr/include/c++/4.8/sstream:38:0, 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 aproape.cpp:1: /usr/include/c++/4.8/istream:58:11: note: 'std::basic_istream<char>::basic_istream(const std::basic_istream<char>&)' is implicitly deleted because the default definition would be ill-formed: class basic_istream : virtual public basic_ios<_CharT, _Traits> ^ /usr/include/c++/4.8/istream:58:11: error: use of deleted function 'std::basic_ios<char>::basic_ios(const std::basic_ios<char>&)' In file included from /usr/include/c++/4.8/ios:44:0, 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 aproape.cpp:1: /usr/include/c++/4.8/bits/basic_ios.h:66:11: note: 'std::basic_ios<char>::basic_ios(const std::basic_ios<char>&)' is implicitly deleted because the default definition would be ill-formed: class basic_ios : public ios_base ^ In file included from /usr/include/c++/4.8/ios:42:0, 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 aproape.cpp:1: /usr/include/c++/4.8/bits/ios_base.h:792:5: error: 'std::ios_base::ios_base(const std::ios_base&)' is private ios_base(const ios_base&); ^ In file included from /usr/include/c++/4.8/ios:44:0, 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 aproape.cpp:1: /usr/include/c++/4.8/bits/basic_ios.h:66:11: error: within this context class basic_ios : public ios_base ^ In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:69:0, from aproape.cpp:1: /usr/include/c++/4.8/fstream:427:11: error: use of deleted function 'std::basic_ios<char>::basic_ios(const std::basic_ios<char>&)' class basic_ifstream : public basic_istream<_CharT, _Traits> ^ /usr/include/c++/4.8/fstream:427:11: error: use of deleted function 'std::basic_filebuf<char>::basic_filebuf(const std::basic_filebuf<char>&)' /usr/include/c++/4.8/fstream:72:11: note: 'std::basic_filebuf<char>::basic_filebuf(const std::basic_filebuf<char>&)' is implicitly deleted because the default definition would be ill-formed: class basic_filebuf : public basic_streambuf<_CharT, _Traits> ^ In file included from /usr/include/c++/4.8/ios:43:0, 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 aproape.cpp:1: /usr/include/c++/4.8/streambuf:802:7: error: 'std::basic_streambuf<_CharT, _Traits>::basic_streambuf(const std::basic_streambuf<_CharT, _Traits>&) [with _CharT = char; _Traits = std::char_traits<char>]' is private basic_streambuf(const basic_streambuf& __sb) ^ In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:69:0, from aproape.cpp:1: /usr/include/c++/4.8/fstream:72:11: error: within this context class basic_filebuf : public basic_streambuf<_CharT, _Traits> ^ aproape.cpp:59:43: error: use of deleted function 'std::basic_ofstream<char>::basic_ofstream(const std::basic_ofstream<char>&)' auto out = std::ofstream("aproape.out"); ^ In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:69:0, from aproape.cpp:1: /usr/include/c++/4.8/fstream:599:11: note: 'std::basic_ofstream<char>::basic_ofstream(const std::basic_ofstream<char>&)' is implicitly deleted because the default definition would be ill-formed: class basic_ofstream : public basic_ostream<_CharT,_Traits> ^ /usr/include/c++/4.8/fstream:599:11: error: use of deleted function 'std::basic_ostream<char>::basic_ostream(const std::basic_ostream<char>&)' In file included from /usr/include/c++/4.8/istream:39:0, 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 aproape.cpp:1: /usr/include/c++/4.8/ostream:58:11: note: 'std::basic_ostream<char>::basic_ostream(const std::basic_ostream<char>&)' is implicitly deleted because the default definition would be ill-formed: class basic_ostream : virtual public basic_ios<_CharT, _Traits> ^ /usr/include/c++/4.8/ostream:58:11: error: use of deleted function 'std::basic_ios<char>::basic_ios(const std::basic_ios<char>&)' In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:69:0, from aproape.cpp:1: /usr/include/c++/4.8/fstream:599:11: error: use of deleted function 'std::basic_ios<char>::basic_ios(const std::basic_ios<char>&)' class basic_ofstream : public basic_ostream<_CharT,_Traits> ^ /usr/include/c++/4.8/fstream:599:11: error: use of deleted function 'std::basic_filebuf<char>::basic_filebuf(const std::basic_filebuf<char>&)' In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from aproape.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h: In instantiation of '_RandomAccessIterator std::__find_if_not(_RandomAccessIterator, _RandomAccessIterator, _Predicate, std::random_access_iterator_tag) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >; _Predicate = isNum(const string&)::__lambda4]': /usr/include/c++/4.8/bits/stl_algo.h:317:38: required from '_InputIterator std::__find_if_not(_InputIterator, _InputIterator, _Predicate) [with _InputIterator = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >; _Predicate = isNum(const string&)::__lambda4]' /usr/include/c++/4.8/bits/stl_algo.h:787:56: required from '_IIter std::find_if_not(_IIter, _IIter, _Predicate) [with _IIter = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >; _Predicate = isNum(const string&)::__lambda4]' /usr/include/c++/4.8/bits/stl_algo.h:730:64: required from 'bool std::all_of(_IIter, _IIter, _Predicate) [with _IIter = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char> >; _Predicate = isNum(const string&)::__lambda4]' aproape.cpp:23:110: required from here /usr/include/c++/4.8/bits/stl_algo.h:273:29: error: no match for call to '(isNum(const string&)::__lambda4) (const char&)' if (!bool(__pred(*__first))) ^ aproape.cpp:23:69: note: candidates are: return s.front() != '0' && std::all_of(s.begin(), s.end(), [](auto c){ return c >= '0' && c <= '9'; }); ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from aproape.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h:273:29: note: void (*)() <conversion> if (!bool(__pred(*__first))) ^ /usr/include/c++/4.8/bits/stl_algo.h:273:29: note: candidate expects 1 argument, 2 provided aproape.cpp:23:77: note: isNum(const string&)::__lambda4 return s.front() != '0' && std::all_of(s.begin(), s.end(), [](auto c){ return c >= '0' && c <= '9'; }); ^ aproape.cpp:23:77: note: candidate expects 0 arguments, 1 provided In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from aproape.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h:277:29: error: no match for call to '(isNum(const string&)::__lambda4) (const char&)' if (!bool(__pred(*__first))) ^ aproape.cpp:23:69: note: candidates are: return s.front() != '0' && std::all_of(s.begin(), s.end(), [](auto c){ return c >= '0' && c <= '9'; }); ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from aproape.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h:277:29: note: void (*)() <conversion> if (!bool(__pred(*__first))) ^ /usr/include/c++/4.8/bits/stl_algo.h:277:29: note: candidate expects 1 argument, 2 provided aproape.cpp:23:77: note: isNum(const string&)::__lambda4 return s.front() != '0' && std::all_of(s.begin(), s.end(), [](auto c){ return c >= '0' && c <= '9'; }); ^ aproape.cpp:23:77: note: candidate expects 0 arguments, 1 provided In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from aproape.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h:281:29: error: no match for call to '(isNum(const string&)::__lambda4) (const char&)' if (!bool(__pred(*__first))) ^ aproape.cpp:23:69: note: candidates are: return s.front() != '0' && std::all_of(s.begin(), s.end(), [](auto c){ return c >= '0' && c <= '9'; }); ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from aproape.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h:281:29: note: void (*)() <conversion> if (!bool(__pred(*__first))) ^ /usr/include/c++/4.8/bits/stl_algo.h:281:29: note: candidate expects 1 argument, 2 provided aproape.cpp:23:77: note: isNum(const string&)::__lambda4 return s.front() != '0' && std::all_of(s.begin(), s.end(), [](auto c){ return c >= '0' && c <= '9'; }); ^ aproape.cpp:23:77: note: candidate expects 0 arguments, 1 provided In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from aproape.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h:285:29: error: no match for call to '(isNum(const string&)::__lambda4) (const char&)' if (!bool(__pred(*__first))) ^ aproape.cpp:23:69: note: candidates are: return s.front() != '0' && std::all_of(s.begin(), s.end(), [](auto c){ return c >= '0' && c <= '9'; }); ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from aproape.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h:285:29: note: void (*)() <conversion> if (!bool(__pred(*__first))) ^ /usr/include/c++/4.8/bits/stl_algo.h:285:29: note: candidate expects 1 argument, 2 provided aproape.cpp:23:77: note: isNum(const string&)::__lambda4 return s.front() != '0' && std::all_of(s.begin(), s.end(), [](auto c){ return c >= '0' && c <= '9'; }); ^ aproape.cpp:23:77: note: candidate expects 0 arguments, 1 provided In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from aproape.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h:293:29: error: no match for call to '(isNum(const string&)::__lambda4) (const char&)' if (!bool(__pred(*__first))) ^ aproape.cpp:23:69: note: candidates are: return s.front() != '0' && std::all_of(s.begin(), s.end(), [](auto c){ return c >= '0' && c <= '9'; }); ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from aproape.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h:293:29: note: void (*)() <conversion> if (!bool(__pred(*__first))) ^ /usr/include/c++/4.8/bits/stl_algo.h:293:29: note: candidate expects 1 argument, 2 provided aproape.cpp:23:77: note: isNum(const string&)::__lambda4 return s.front() != '0' && std::all_of(s.begin(), s.end(), [](auto c){ return c >= '0' && c <= '9'; }); ^ aproape.cpp:23:77: note: candidate expects 0 arguments, 1 provided In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from aproape.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h:297:29: error: no match for call to '(isNum(const string&)::__lambda4) (const char&)' if (!bool(__pred(*__first))) ^ aproape.cpp:23:69: note: candidates are: return s.front() != '0' && std::all_of(s.begin(), s.end(), [](auto c){ return c >= '0' && c <= '9'; }); ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from aproape.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h:297:29: note: void (*)() <conversion> if (!bool(__pred(*__first))) ^ /usr/include/c++/4.8/bits/stl_algo.h:297:29: note: candidate expects 1 argument, 2 provided aproape.cpp:23:77: note: isNum(const string&)::__lambda4 return s.front() != '0' && std::all_of(s.begin(), s.end(), [](auto c){ return c >= '0' && c <= '9'; }); ^ aproape.cpp:23:77: note: candidate expects 0 arguments, 1 provided In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from aproape.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h:301:29: error: no match for call to '(isNum(const string&)::__lambda4) (const char&)' if (!bool(__pred(*__first))) ^ aproape.cpp:23:69: note: candidates are: return s.front() != '0' && std::all_of(s.begin(), s.end(), [](auto c){ return c >= '0' && c <= '9'; }); ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from aproape.cpp:1: /usr/include/c++/4.8/bits/stl_algo.h:301:29: note: void (*)() <conversion> if (!bool(__pred(*__first))) ^ /usr/include/c++/4.8/bits/stl_algo.h:301:29: note: candidate expects 1 argument, 2 provided aproape.cpp:23:77: note: isNum(const string&)::__lambda4 return s.front() != '0' && std::all_of(s.begin(), s.end(), [](auto c){ return c >= '0' && c <= '9'; }); ^ aproape.cpp:23:77: note: candidate expects 0 arguments, 1 provided
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Aproape 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ă.