#2666
Trim
C++
Scrieți funcția Trim
care primește ca parametru un șir de caractere s
, elimină eventualele spații de la începutul și sfârșitul șirului și returnează tot prin intermediul lui s
șirul de caractere rezultat.
Folclorul informatic
Problema | Trim | Operații I/O |
![]() trim.in /trim.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #54975090 | Utilizator | |
Fișier | trim.cpp | Dimensiune | 738 B |
Data încărcării | 14 Decembrie 2024, 13:02 | Scor / rezultat | Eroare de compilare |
trim.cpp:15:14: warning: character constant too long for its type [enabled by default] char s[]='Azi avem informatica'; ^ trim.cpp: In function 'int main()': trim.cpp:15:12: error: redeclaration of 'char s []' char s[]='Azi avem informatica'; ^ trim.cpp:14:10: error: 'char s [20]' previously declared here char s[20]; ^ trim.cpp:16:12: error: redeclaration of 'char s []' char s[]="elefant"; ^ trim.cpp:14:10: error: 'char s [20]' previously declared here char s[20]; ^ trim.cpp: At global scope: trim.cpp:23:11: error: variable or field 'trim' declared void void trim(chars[101]) ^ trim.cpp:23:11: error: 'chars' was not declared in this scope trim.cpp: In function 'int main()': trim.cpp:33:5: error: redefinition of 'int main()' int main() ^ trim.cpp:11:5: error: 'int main()' previously defined here int main() ^ trim.cpp:36:22: error: invalid conversion from 'char' to 'std::basic_istream<char>::char_type* {aka char*}' [-fpermissive] cin.getline(T,101); ^ In file included from /usr/include/c++/4.8/fstream:38:0, from trim.cpp:1: /usr/include/c++/4.8/istream:427:7: error: initializing argument 1 of '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]' [-fpermissive] getline(char_type* __s, streamsize __n) ^ trim.cpp:37:11: error: 'Trim' was not declared in this scope Trim(T); ^ trim.cpp:42:1: error: a function-definition is not allowed here before '{' token { ^ trim.cpp:51:1: error: expected '}' at end of input } ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Trim 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ă.