#807
Inlocuire1
Se dă un şir de caractere ce conţine cuvinte formate din litere mici ale alfabetului englez, separate prin unul sau mai multe spații. Înaintea primului cuvânt nu există spații, și nici după ultimul. Să se modifice șirul dat, astfel încât să se înlocuiască fiecare cuvânt cu exact trei litere din șir cu simbolul *
.
Variante Bacalaureat 2013
Problema | Inlocuire1 | Operații I/O | tastatură/ecran |
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #53803640 | Utilizator | |
Fișier | inlocuire1.cpp | Dimensiune | 506 B |
Data încărcării | 12 Noiembrie 2024, 09:31 | Scor / rezultat | Eroare de compilare |
inlocuire1.cpp:4:14: warning: overflow in implicit constant conversion [-Woverflow] char text(260),aux[256]; ^ inlocuire1.cpp: In function 'int main()': inlocuire1.cpp:7:25: error: invalid conversion from 'char' to 'std::basic_istream<char>::char_type* {aka char*}' [-fpermissive] cin.getline(text,260); ^ In file included from /usr/include/c++/4.8/iostream:40:0, from inlocuire1.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) ^ inlocuire1.cpp:9:24: error: invalid conversion from 'char' to 'const char*' [-fpermissive] while(i<strlen(text)){ ^ In file included from /usr/include/c++/4.8/cstring:42:0, from inlocuire1.cpp:2: /usr/include/string.h:399:15: error: initializing argument 1 of 'size_t strlen(const char*)' [-fpermissive] extern size_t strlen (const char *__s) ^ inlocuire1.cpp:9:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] while(i<strlen(text)){ ^ inlocuire1.cpp:10:28: error: invalid conversion from 'char' to 'const char*' [-fpermissive] while(i<strlen(text)and text[i]==' ') i=i+1; ^ In file included from /usr/include/c++/4.8/cstring:42:0, from inlocuire1.cpp:2: /usr/include/string.h:399:15: error: initializing argument 1 of 'size_t strlen(const char*)' [-fpermissive] extern size_t strlen (const char *__s) ^ inlocuire1.cpp:10:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] while(i<strlen(text)and text[i]==' ') i=i+1; ^ inlocuire1.cpp:10:39: error: invalid types 'char[int]' for array subscript while(i<strlen(text)and text[i]==' ') i=i+1; ^ inlocuire1.cpp:12:9: error: expected ';' before 'while' while(j<strlen(text) and text[j]!=' ') j=j+1; ^ inlocuire1.cpp:12:53: warning: statement has no effect [-Wunused-value] while(j<strlen(text) and text[j]!=' ') j=j+1; ^ inlocuire1.cpp:13:15: error: lvalue required as left operand of assignment if(j-i=3){ ^ inlocuire1.cpp:14:28: error: invalid conversion from 'int' to 'const char*' [-fpermissive] strcpy(aux,text+j); ^ In file included from /usr/include/features.h:374:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/os_defines.h:39, from /usr/include/i386-linux-gnu/c++/4.8/bits/c++config.h:426, from /usr/include/c++/4.8/iostream:38, from inlocuire1.cpp:1: /usr/include/i386-linux-gnu/bits/string3.h:102:1: error: initializing argument 2 of 'char* strcpy(char*, const char*)' [-fpermissive] __NTH (strcpy (char *__restrict __dest, const char *__restrict __src)) ^ inlocuire1.cpp:15:26: error: invalid conversion from 'int' to 'char*' [-fpermissive] strcpy(text+i+1,aux); ^ In file included from /usr/include/features.h:374:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/os_defines.h:39, from /usr/include/i386-linux-gnu/c++/4.8/bits/c++config.h:426, from /usr/include/c++/4.8/iostream:38, from inlocuire1.cpp:1: /usr/include/i386-linux-gnu/bits/string3.h:102:1: error: initializing argument 1 of 'char* strcpy(char*, const char*)' [-fpermissive] __NTH (strcpy (char *__restrict __dest, const char *__restrict __src)) ^ inlocuire1.cpp:16:19: error: invalid types 'char[int]' for array subscript text[i]='*'; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Inlocuire1 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ă.