#3269
ReverseWords
C++
Scrieți funcția având următorul antet:
void ReverseWords(char s[])
Funcția primește ca parametru un șir s
format din cuvinte separate prin câte un spațiu. Cuvintele sunt formate doar din litere mici. Funcția va returna, tot prin intermediul parametrului s
, cuvintele în ordine inversă, separate tot prin câte un spațiu.
Problemă de interviu
Problema | ReverseWords | Operații I/O |
reversewords.in /reversewords.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 1 MB
/
Stivă 1 MB
|
Id soluție | #50550802 | Utilizator | |
Fișier | reversewords.cpp | Dimensiune | 550 B |
Data încărcării | 14 Aprilie 2024, 21:46 | Scor / rezultat | Eroare de compilare |
reversewords.cpp: In function 'void ReverseWords(char*)': reversewords.cpp:21:17: error: 'strrev' was not declared in this scope strrev(p); ^ reversewords.cpp: In function 'int main()': reversewords.cpp:32:22: error: no matching function for call to 'std::basic_istream<char>::getline(int [101], int)' cin.getline(s,101); ^ reversewords.cpp:32:22: note: candidates are: In file included from /usr/include/c++/4.8/fstream:38:0, from reversewords.cpp:1: /usr/include/c++/4.8/istream:618:5: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::getline(std::basic_istream<_CharT, _Traits>::char_type*, std::streamsize, std::basic_istream<_CharT, _Traits>::char_type) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::char_type = char; std::streamsize = int] basic_istream<char>:: ^ /usr/include/c++/4.8/istream:618:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/4.8/istream:427:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::getline(std::basic_istream<_CharT, _Traits>::char_type*, std::streamsize) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>; std::basic_istream<_CharT, _Traits>::char_type = char; std::streamsize = int] getline(char_type* __s, streamsize __n) ^ /usr/include/c++/4.8/istream:427:7: note: no known conversion for argument 1 from 'int [101]' to 'std::basic_istream<char>::char_type* {aka char*}' reversewords.cpp:33:25: error: cannot convert 'int*' to 'char*' for argument '1' to 'void ReverseWords(char*)' cout<<ReverseWords(s); ^ reversewords.cpp: In function 'int main()': reversewords.cpp:38:5: error: redefinition of 'int main()' int main() ^ reversewords.cpp:29:5: error: 'int main()' previously defined here int main() ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema ReverseWords 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ă.