#4763
Într-un text, de cel mult 100 de caractere, cuvintele sunt formate din litere ale alfabetului englez și sunt separate prin spații. Scrieți un program C/C++ care citește de la tastatură un text de tipul precizat mai sus și afișează pe ecran mesajul DA și un număr natural n, separate printr-un spațiu, dacă toate cuvintele din text au câte n litere, sau mesajul NU în cazul în care nu toate cuvintele au același număr de litere.
Bacalaureat 2024
| Problema | CuvinteLungimiEgale | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 8 MB
/
Stivă 2 MB
|
| Id soluție | #61754703 | Utilizator | |
| Fișier | cuvintelungimiegale.cpp | Dimensiune | 297 B |
| Data încărcării | 09 Decembrie 2025, 09:38 | Scor/rezultat | Eroare de compilare |
cuvintelungimiegale.cpp: In function 'int main()': cuvintelungimiegale.cpp:7:13: error: expected ')' before numeric constant cin.get (s 201); ^ cuvintelungimiegale.cpp:7:16: error: no matching function for call to 'std::basic_istream<char>::get(char [201])' cin.get (s 201); ^ cuvintelungimiegale.cpp:7:16: note: candidates are: In file included from /usr/include/c++/4.8/iostream:40:0, from cuvintelungimiegale.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 [201]' 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 [201]' to 'std::basic_istream<char>::__streambuf_type& {aka std::basic_streambuf<char>&}' cuvintelungimiegale.cpp:8:13: error: expected ')' before string constant p=strtok(s " "); ^ cuvintelungimiegale.cpp:8:16: error: too few arguments to function 'char* strtok(char*, const char*)' p=strtok(s " "); ^ In file included from /usr/include/c++/4.8/cstring:42:0, from cuvintelungimiegale.cpp:2: /usr/include/string.h:348:14: note: declared here extern char *strtok (char *__restrict __s, const char *__restrict __delim) ^ cuvintelungimiegale.cpp:11:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] {if(strlen(p)!=n) ^ cuvintelungimiegale.cpp:12:6: error: 'ok' was not declared in this scope ok=0; ^ cuvintelungimiegale.cpp:13:20: error: expected ')' before string constant p=strtok(NULL " "); ^ cuvintelungimiegale.cpp:13:23: error: too few arguments to function 'char* strtok(char*, const char*)' p=strtok(NULL " "); ^ In file included from /usr/include/c++/4.8/cstring:42:0, from cuvintelungimiegale.cpp:2: /usr/include/string.h:348:14: note: declared here extern char *strtok (char *__restrict __s, const char *__restrict __delim) ^ cuvintelungimiegale.cpp:14:6: error: 'ok' was not declared in this scope }IF(ok==0) ^ cuvintelungimiegale.cpp:14:11: error: 'IF' was not declared in this scope }IF(ok==0) ^ cuvintelungimiegale.cpp:15:6: error: expected ';' before 'cout' cout<<"Nu"; ^ cuvintelungimiegale.cpp:16:2: error: 'else' without a previous 'if' else ^ cuvintelungimiegale.cpp:6:8: warning: unused variable 'k' [-Wunused-variable] int n,k; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema CuvinteLungimiEgale 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ă.