#4238
NrZero
C++
Scrieţi definiția completă a subprogramului C++ cu antetul:
int NrZero(int a[], int n)
care are doi parametri:
a
, prin care primeşte un tablou unidimensional care memorează numai cifre, astfel: cifrele impare se află la începutul vectorului ordonate descrescător, iar cifrele pare se găsesc la finalul vectorului, ordonate crescătorn
, numărul efectiv de elemente ale tablouluiSubprogramul returnează numărul de valori egale cu 0
din vectorul a
.
Folclorul informatic
Problema | NrZero | Operații I/O |
nrzero.in /nrzero.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 128 MB
/
Stivă 64 MB
|
Id soluție | #46094854 | Utilizator | |
Fișier | nrzero.cpp | Dimensiune | 323 B |
Data încărcării | 02 Noiembrie 2023, 18:40 | Scor / rezultat | Eroare de compilare |
nrzero.cpp:29:14: error: conflicting declaration 'char s [500003]' char s[500003]; ^ nrzero.cpp:7:25: error: 's' has a previous declaration as 'int s' int n, a[1001], s1, s2, s,k; ^ nrzero.cpp:30:5: error: redefinition of 'int n' int n, a[500003]; ^ nrzero.cpp:7:5: error: 'int n' previously declared here int n, a[1001], s1, s2, s,k; ^ nrzero.cpp:30:16: error: conflicting declaration 'int a [500003]' int n, a[500003]; ^ nrzero.cpp:7:8: error: 'a' has a previous declaration as 'int a [1001]' int n, a[1001], s1, s2, s,k; ^ nrzero.cpp: In function 'int main()': nrzero.cpp:32:5: error: redefinition of 'int main()' int main() ^ nrzero.cpp:17:5: error: 'int main()' previously defined here int main() ^ nrzero.cpp:37:9: error: ambiguous overload for 'operator>>' (operand types are 'std::ifstream {aka std::basic_ifstream<char>}' and 'int') fin >> (s + 1); ^ nrzero.cpp:37:9: note: candidates are: 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 nrzero.cpp:1: /usr/include/c++/4.8/istream:120:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__istream_type& (*)(std::basic_istream<_CharT, _Traits>::__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>] <near match> operator>>(__istream_type& (*__pf)(__istream_type&)) ^ /usr/include/c++/4.8/istream:120:7: note: no known conversion for argument 1 from 'int' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&) {aka std::basic_istream<char>& (*)(std::basic_istream<char>&)}' /usr/include/c++/4.8/istream:124:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__ios_type& (*)(std::basic_istream<_CharT, _Traits>::__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>; std::basic_istream<_CharT, _Traits>::__ios_type = std::basic_ios<char>] <near match> operator>>(__ios_type& (*__pf)(__ios_type&)) ^ /usr/include/c++/4.8/istream:124:7: note: no known conversion for argument 1 from 'int' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&) {aka std::basic_ios<char>& (*)(std::basic_ios<char>&)}' /usr/include/c++/4.8/istream:131:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>] <near match> operator>>(ios_base& (*__pf)(ios_base&)) ^ /usr/include/c++/4.8/istream:131:7: note: no known conversion for argument 1 from 'int' to 'std::ios_base& (*)(std::ios_base&)' /usr/include/c++/4.8/istream:259:7: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__streambuf_type*) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__streambuf_type = std::basic_streambuf<char>] <near match> operator>>(__streambuf_type* __sb); ^ /usr/include/c++/4.8/istream:259:7: note: no known conversion for argument 1 from 'int' to 'std::basic_istream<char>::__streambuf_type* {aka std::basic_streambuf<char>*}' nrzero.cpp:39:18: error: invalid conversion from 'int' to 'const char*' [-fpermissive] n = strlen(s + 1); ^ In file included from /usr/include/c++/4.8/cstring:42:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:48, from nrzero.cpp:1: /usr/include/string.h:399:15: error: initializing argument 1 of 'size_t strlen(const char*)' [-fpermissive] extern size_t strlen (const char *__s) ^ nrzero.cpp:41:19: error: invalid types 'int[int]' for array subscript a[i] = s[i] - '0'; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema NrZero 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ă.