#2304
Cuvinte7
Scrieţi un program care citeşte de la tastatură, în această ordine, un număr natural n
, apoi n
cuvinte, separate prin Enter, urmate de un număr natural k
. Numerele citite sunt din intervalul [1,20]
, iar fiecare cuvânt este format din cel mult 20
de caractere, numai litere mici ale alfabetului englez. Cel puţin unul dintre cuvinte are k
litere.
Programul construiește în memorie, apoi afișează pe ecran, un șir care să cuprindă cuvintele citite, separate prin câte un spațiu, astfel încât toate cele care au k
litere să ocupe primele poziţii, iar celelalte să se regăsească în continuarea acestora, într-o ordine oarecare.
Subiect Bacalaureat 2016, sesiunea specială
Problema | Cuvinte7 | Operații I/O | tastatură/ecran |
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #54941592 | Utilizator | |
Fișier | cuvinte7.cpp | Dimensiune | 439 B |
Data încărcării | 12 Decembrie 2024, 21:39 | Scor / rezultat | Eroare de compilare |
cuvinte7.cpp: In function 'int main()': cuvinte7.cpp:10:14: error: no matching function for call to 'std::basic_istream<char>::get(char [21])' cin.get(s); ^ cuvinte7.cpp:10:14: note: candidates are: In file included from /usr/include/c++/4.8/iostream:40:0, from cuvinte7.cpp:1: /usr/include/c++/4.8/istream:302:7: note: std::basic_istream<_CharT, _Traits>::int_type std::basic_istream<_CharT, _Traits>::get() [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::int_type = int] get(); ^ /usr/include/c++/4.8/istream:302:7: note: candidate expects 0 arguments, 1 provided /usr/include/c++/4.8/istream:316:7: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::get(std::basic_istream<_CharT, _Traits>::char_type&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::char_type = char] get(char_type& __c); ^ /usr/include/c++/4.8/istream:316:7: note: no known conversion for argument 1 from 'char [21]' to 'std::basic_istream<char>::char_type& {aka char&}' /usr/include/c++/4.8/istream:343:7: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::get(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] get(char_type* __s, streamsize __n, char_type __delim); ^ /usr/include/c++/4.8/istream:343:7: note: candidate expects 3 arguments, 1 provided /usr/include/c++/4.8/istream:354:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::get(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] get(char_type* __s, streamsize __n) ^ /usr/include/c++/4.8/istream:354:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/4.8/istream:377:7: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::get(std::basic_istream<_CharT, _Traits>::__streambuf_type&, std::basic_istream<_CharT, _Traits>::char_type) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__streambuf_type = std::basic_streambuf<char>; std::basic_istream<_CharT, _Traits>::char_type = char] get(__streambuf_type& __sb, char_type __delim); ^ /usr/include/c++/4.8/istream:377:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/4.8/istream:387:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::get(std::basic_istream<_CharT, _Traits>::__streambuf_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>::__streambuf_type = std::basic_streambuf<char>] get(__streambuf_type& __sb) ^ /usr/include/c++/4.8/istream:387:7: note: no known conversion for argument 1 from 'char [21]' to 'std::basic_istream<char>::__streambuf_type& {aka std::basic_streambuf<char>&}' cuvinte7.cpp:14:22: error: invalid conversion from 'char' to 'const char*' [-fpermissive] if(strlen(s[i])==k) ^ In file included from /usr/include/c++/4.8/cstring:42:0, from cuvinte7.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) ^ cuvinte7.cpp:14:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if(strlen(s[i])==k) ^ cuvinte7.cpp:15:27: error: invalid conversion from 'char' to 'const char*' [-fpermissive] strcat(rez,s[i]), strcat(rez," "); ^ 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 cuvinte7.cpp:1: /usr/include/i386-linux-gnu/bits/string3.h:140:1: error: initializing argument 2 of 'char* strcat(char*, const char*)' [-fpermissive] __NTH (strcat (char *__restrict __dest, const char *__restrict __src)) ^ cuvinte7.cpp:17:22: error: invalid conversion from 'char' to 'const char*' [-fpermissive] if(strlen(s[i])!=k) ^ In file included from /usr/include/c++/4.8/cstring:42:0, from cuvinte7.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) ^ cuvinte7.cpp:17:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if(strlen(s[i])!=k) ^ cuvinte7.cpp:18:27: error: invalid conversion from 'char' to 'const char*' [-fpermissive] strcat(rez,s[i]), strcat(rez," "); ^ 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 cuvinte7.cpp:1: /usr/include/i386-linux-gnu/bits/string3.h:140:1: error: initializing argument 2 of 'char* strcat(char*, const char*)' [-fpermissive] __NTH (strcat (char *__restrict __dest, const char *__restrict __src)) ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Cuvinte7 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ă.