#488
Afisare
Se citește un vector cu n
elemente, numere naturale. Să se afișeze elementele cu indici pari în ordinea crescătoare a indicilor, iar elementele cu indici impari în ordinea descrescătoare a indicilor.
Problema | Afisare | Operații I/O | tastatură/ecran |
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #4208730 | Utilizator | |
Fișier | afisare.cpp | Dimensiune | 477 B |
Data încărcării | 31 Ianuarie 2017, 20:40 | Scor / rezultat | Eroare de compilare |
afisare.cpp: In function 'int main()': afisare.cpp:11:23: error: request for member 'size' in 'a', which is of non-class type 'std::vector<int> [(((sizetype)(((ssizetype)n) + -1)) + 1)]' for (int i=0; i<a.size(); i++) ^ afisare.cpp:12:19: error: cannot bind 'std::istream {aka std::basic_istream<char>}' lvalue to 'std::basic_istream<char>&&' cin >> a[i]; ^ In file included from /usr/include/c++/4.8/iostream:40:0, from afisare.cpp:1: /usr/include/c++/4.8/istream:872:5: error: initializing argument 1 of 'std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&&, _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = std::vector<int>]' operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x) ^ afisare.cpp:13:23: error: request for member 'size' in 'a', which is of non-class type 'std::vector<int> [(((sizetype)(((ssizetype)n) + -1)) + 1)]' for (int i=0; i<a.size(); i++) ^ afisare.cpp:14:41: error: no matching function for call to 'std::vector<int>::push_back(std::vector<int>&)' if ((i+1)%2==0) x.push_back(a[i]); ^ afisare.cpp:14:41: note: candidates are: In file included from /usr/include/c++/4.8/vector:64:0, from afisare.cpp:2: /usr/include/c++/4.8/bits/stl_vector.h:901:7: note: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int] push_back(const value_type& __x) ^ /usr/include/c++/4.8/bits/stl_vector.h:901:7: note: no known conversion for argument 1 from 'std::vector<int>' to 'const value_type& {aka const int&}' /usr/include/c++/4.8/bits/stl_vector.h:919:7: note: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int] push_back(value_type&& __x) ^ /usr/include/c++/4.8/bits/stl_vector.h:919:7: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::value_type&& {aka int&&}' afisare.cpp:15:30: error: no matching function for call to 'std::vector<int>::push_back(std::vector<int>&)' else y.push_back(a[i]); ^ afisare.cpp:15:30: note: candidates are: In file included from /usr/include/c++/4.8/vector:64:0, from afisare.cpp:2: /usr/include/c++/4.8/bits/stl_vector.h:901:7: note: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int] push_back(const value_type& __x) ^ /usr/include/c++/4.8/bits/stl_vector.h:901:7: note: no known conversion for argument 1 from 'std::vector<int>' to 'const value_type& {aka const int&}' /usr/include/c++/4.8/bits/stl_vector.h:919:7: note: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int] push_back(value_type&& __x) ^ /usr/include/c++/4.8/bits/stl_vector.h:919:7: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::value_type&& {aka int&&}' afisare.cpp:16:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (int i=0; i<x.size(); i++) ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Afisare 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ă.