#2828
Se consideră un text cu cel mult 100 de caractere, în care cuvintele sunt formate numai din litere mari și mici ale alfabetului englez și sunt separate prin câte un spațiu. Textul reprezintă numele unei instituții sau al unei organizații.
Scrieți un program care citește de la tastatură un text de tipul precizat și construiește în memorie, apoi afișează pe ecran, un șir de caractere ce reprezintă acronimul corespunzător numelui citit. Acronimul este format din primul caracter al fiecărui cuvânt al numelui care începe cu majusculă.
Subiect Bacalaureat 2015, sesiunea specială
| Problema | Acronim | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64075685 | Utilizator | |
| Fișier | acronim.cpp | Dimensiune | 323 B |
| Data încărcării | 15 Aprilie 2026, 18:46 | Scor/rezultat | Eroare de compilare |
acronim.cpp:15:52: warning: missing terminating ' character 15 | if(s[i-1] == ' ' && s[i] >= 'A' && s[i] <= 'Z) | ^ acronim.cpp:15:52: error: missing terminating ' character 15 | if(s[i-1] == ' ' && s[i] >= 'A' && s[i] <= 'Z) | ^~~ acronim.cpp: In function ‘int main()’: acronim.cpp:15:12: warning: init-statement in selection statements only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions] 15 | if(s[i-1] == ' ' && s[i] >= 'A' && s[i] <= 'Z) | ^ acronim.cpp:15:49: error: no match for ‘operator<=’ (operand types are ‘char’ and ‘std::basic_ostream<char>’) 15 | if(s[i-1] == ' ' && s[i] >= 'A' && s[i] <= 'Z) | ~~~~ ^~ | | | char 16 | cout << s[i]; | ~~~~~~~~~~~~ | | | std::basic_ostream<char> acronim.cpp:15:49: note: candidate: ‘operator<=(int, int)’ (built-in) 15 | if(s[i-1] == ' ' && s[i] >= 'A' && s[i] <= 'Z) | ~~~~~^~~~~~ 16 | cout << s[i]; | ~~~~~~~~~~~~ acronim.cpp:15:49: note: no known conversion for argument 2 from ‘std::basic_ostream<char>’ to ‘int’ In file included from /usr/include/c++/13/string:48, from /usr/include/c++/13/bits/locale_classes.h:40, from /usr/include/c++/13/bits/ios_base.h:41, from /usr/include/c++/13/ios:44, from /usr/include/c++/13/ostream:40, from /usr/include/c++/13/iostream:41, from acronim.cpp:1: /usr/include/c++/13/bits/stl_iterator.h:476:5: note: candidate: ‘template<class _Iterator> bool std::operator<=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)’ 476 | operator<=(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/13/bits/stl_iterator.h:476:5: note: template argument deduction/substitution failed: acronim.cpp:16:24: note: mismatched types ‘const std::reverse_iterator<_Iterator>’ and ‘char’ 16 | cout << s[i]; | ^ /usr/include/c++/13/bits/stl_iterator.h:520:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> bool std::operator<=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)’ 520 | operator<=(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/13/bits/stl_iterator.h:520:5: note: template argument deduction/substitution failed: acronim.cpp:16:24: note: mismatched types ‘const std::reverse_iterator<_Iterator>’ and ‘char’ 16 | cout << s[i]; | ^ /usr/include/c++/13/bits/stl_iterator.h:1715:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> bool std::operator<=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)’ 1715 | operator<=(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/13/bits/stl_iterator.h:1715:5: note: template argument deduction/substitution failed: acronim.cpp:16:24: note: mismatched types ‘const std::move_iterator<_IteratorL>’ and ‘char’ 16 | cout << s[i]; | ^ /usr/include/c++/13/bits/stl_iterator.h:1777:5: note: candidate: ‘template<class _Iterator> bool std::operator<=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)’ 1777 | operator<=(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/13/bits/stl_iterator.h:1777:5: note: template argument deduction/substitution failed: acronim.cpp:16:24: note: mismatched types ‘const std::move_iterator<_IteratorL>’ and ‘char’ 16 | cout << s[i]; | ^ In file included from /usr/include/c++/13/bits/stl_algobase.h:64, from /usr/include/c++/13/string:51: /usr/include/c++/13/bits/stl_pair.h:854:5: note: candidate: ‘template<class _T1, class _T2> constexpr bool std::operator<=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)’ 854 | operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/13/bits/stl_pair.h:854:5: note: template argument deduction/substitution failed: acronim.cpp:16:24: note: mismatched types ‘const std::pair<_T1, _T2>’ and ‘char’ 16 | cout << s[i]; | ^ In file included from /usr/include/c++/13/string:54: /usr/include/c++/13/bits/basic_string.h:3911:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> bool std::operator<=(const __cxx11::basic_string<_CharT, _Traits, _Alloc>&, const __cxx11::basic_string<_CharT, _Traits, _Alloc>&)’ 3911 | operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/13/bits/basic_string.h:3911:5: note: template argument deduction/substitution failed: acronim.cpp:16:24: note: mismatched types ‘const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>’ and ‘char’ 16 | cout << s[i]; | ^ /usr/include/c++/13/bits/basic_string.h:3925:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> bool std::operator<=(const __cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)’ 3925 | operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/13/bits/basic_string.h:3925:5: note: template argument deduction/substitution failed: acronim.cpp:16:24: note: mismatched types ‘const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>’ and ‘char’ 16 | cout << s[i]; | ^ /usr/include/c++/13/bits/basic_string.h:3938:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> bool std::operator<=(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Alloc>&)’ 3938 | operator<=(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/13/bits/basic_string.h:3938:5: note: template argument deduction/substitution failed: acronim.cpp:16:24: note: mismatched types ‘const _CharT*’ and ‘char’ 16 | cout << s[i]; | ^ acronim.cpp:17:5: error: expected primary-expression before ‘}’ token 17 | } | ^ acronim.cpp:16:26: error: expected ‘)’ before ‘}’ token 16 | cout << s[i]; | ^ | ) 17 | } | ~ acronim.cpp:15:11: note: to match this ‘(’ 15 | if(s[i-1] == ' ' && s[i] >= 'A' && s[i] <= 'Z) | ^ acronim.cpp:17:5: error: expected primary-expression before ‘}’ token 17 | } | ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Acronim 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ă.