#3187
Se dau două numere n p și o listă de n elemente cu urcările în autobuz a mai multor persoane a căror structura este prenume nume bilet_platit, fiecare intrare fiind plasată pe câte o linie. Câmpurile prenume și nume sunt șiruri de caractere, iar bilet_platit este un număr care poate fi 0 sau 1; 0 dacă persoana respectivă nu a plătit biletul sau 1 dacă a plătit biletul. Pentru fiecare bilet neplătit se va contoriza o penalizare persoanei.
Se cere :
a) Prenumele, numele și numărul de penalizări al persoanei care are număr maxim de penalizări. Dacă există mai multe persoane cu număr maxim de penalizări se cere afișarea persoanei care apare prima în ordine alfabetică.
b) Ordonarea listei de persoane descrescător după numărul de penalizări, la număr de penalizări egale, crescător după prenume, la prenume identice, crescător după nume.
| Problema | RATC2 | Operații I/O |
ratc2.in/ratc2.out
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64404651 | Utilizator | |
| Fișier | ratc2.cpp | Dimensiune | 1.78 KB |
| Data încărcării | 05 Mai 2026, 12:59 | Scor/rezultat | Eroare de compilare |
ratc2.cpp: In function ‘void citire(int&, int&, int&, persoana*)’: ratc2.cpp:20:35: error: no match for ‘operator>’ (operand types are ‘std::basic_istream<char>’ and ‘int’) 20 | fin>>aux.nume>>aux.prenume>aux.b; | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ | | | | | int | std::basic_istream<char> ratc2.cpp:20:35: note: candidate: ‘operator>(int, int)’ (built-in) 20 | fin>>aux.nume>>aux.prenume>aux.b; | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ ratc2.cpp:20:35: note: no known conversion for argument 1 from ‘std::basic_istream<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 ratc2.cpp:1: /usr/include/c++/13/bits/stl_iterator.h:469:5: note: candidate: ‘template<class _Iterator> bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)’ 469 | operator>(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/13/bits/stl_iterator.h:469:5: note: template argument deduction/substitution failed: ratc2.cpp:20:40: note: ‘std::basic_istream<char>’ is not derived from ‘const std::reverse_iterator<_Iterator>’ 20 | fin>>aux.nume>>aux.prenume>aux.b; | ^ /usr/include/c++/13/bits/stl_iterator.h:514:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)’ 514 | operator>(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/13/bits/stl_iterator.h:514:5: note: template argument deduction/substitution failed: ratc2.cpp:20:40: note: ‘std::basic_istream<char>’ is not derived from ‘const std::reverse_iterator<_Iterator>’ 20 | fin>>aux.nume>>aux.prenume>aux.b; | ^ /usr/include/c++/13/bits/stl_iterator.h:1725:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)’ 1725 | operator>(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/13/bits/stl_iterator.h:1725:5: note: template argument deduction/substitution failed: ratc2.cpp:20:40: note: ‘std::basic_istream<char>’ is not derived from ‘const std::move_iterator<_IteratorL>’ 20 | fin>>aux.nume>>aux.prenume>aux.b; | ^ /usr/include/c++/13/bits/stl_iterator.h:1784:5: note: candidate: ‘template<class _Iterator> bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)’ 1784 | operator>(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/13/bits/stl_iterator.h:1784:5: note: template argument deduction/substitution failed: ratc2.cpp:20:40: note: ‘std::basic_istream<char>’ is not derived from ‘const std::move_iterator<_IteratorL>’ 20 | fin>>aux.nume>>aux.prenume>aux.b; | ^ 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:848:5: note: candidate: ‘template<class _T1, class _T2> constexpr bool std::operator>(const pair<_T1, _T2>&, const pair<_T1, _T2>&)’ 848 | operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/13/bits/stl_pair.h:848:5: note: template argument deduction/substitution failed: ratc2.cpp:20:40: note: ‘std::basic_istream<char>’ is not derived from ‘const std::pair<_T1, _T2>’ 20 | fin>>aux.nume>>aux.prenume>aux.b; | ^ In file included from /usr/include/c++/13/string:54: /usr/include/c++/13/bits/basic_string.h:3870: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>&)’ 3870 | operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/13/bits/basic_string.h:3870:5: note: template argument deduction/substitution failed: ratc2.cpp:20:40: note: ‘std::basic_istream<char>’ is not derived from ‘const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>’ 20 | fin>>aux.nume>>aux.prenume>aux.b; | ^ /usr/include/c++/13/bits/basic_string.h:3884:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const __cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)’ 3884 | operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/13/bits/basic_string.h:3884:5: note: template argument deduction/substitution failed: ratc2.cpp:20:40: note: ‘std::basic_istream<char>’ is not derived from ‘const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>’ 20 | fin>>aux.nume>>aux.prenume>aux.b; | ^ /usr/include/c++/13/bits/basic_string.h:3897:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Alloc>&)’ 3897 | operator>(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/13/bits/basic_string.h:3897:5: note: template argument deduction/substitution failed: ratc2.cpp:20:40: note: mismatched types ‘const _CharT*’ and ‘std::basic_istream<char>’ 20 | fin>>aux.nume>>aux.prenume>aux.b; | ^ ratc2.cpp:22:41: warning: the address of ‘persoana::nume’ will never be NULL [-Waddress] 22 | if(strcmp(aux.nume,a[j].nume==0)&&strcmp(aux.prenume,a[j].prenume==0) | ~~~~~~~~~^~~ ratc2.cpp:7:10: note: ‘persoana::nume’ declared here 7 | char nume[100],prenume[100]; | ^~~~ ratc2.cpp:22:41: error: cannot convert ‘bool’ to ‘const char*’ 22 | if(strcmp(aux.nume,a[j].nume==0)&&strcmp(aux.prenume,a[j].prenume==0) | ~~~~~~~~~^~~ | | | bool In file included from /usr/include/c++/13/cstring:42, from ratc2.cpp:2: /usr/include/string.h:156:50: note: initializing argument 2 of ‘int strcmp(const char*, const char*)’ 156 | extern int strcmp (const char *__s1, const char *__s2) | ~~~~~~~~~~~~^~~~ ratc2.cpp:22:78: warning: the address of ‘persoana::prenume’ will never be NULL [-Waddress] 22 | if(strcmp(aux.nume,a[j].nume==0)&&strcmp(aux.prenume,a[j].prenume==0) | ~~~~~~~~~~~~^~~ ratc2.cpp:7:20: note: ‘persoana::prenume’ declared here 7 | char nume[100],prenume[100]; | ^~~~~~~ ratc2.cpp:22:78: error: cannot convert ‘bool’ to ‘const char*’ 22 | if(strcmp(aux.nume,a[j].nume==0)&&strcmp(aux.prenume,a[j].prenume==0) | ~~~~~~~~~~~~^~~ | | | bool /usr/include/string.h:156:50: note: initializing argument 2 of ‘int strcmp(const char*, const char*)’ 156 | extern int strcmp (const char *__s1, const char *__s2) | ~~~~~~~~~~~~^~~~ ratc2.cpp:22:82: error: expected ‘)’ before ‘{’ token 22 | if(strcmp(aux.nume,a[j].nume==0)&&strcmp(aux.prenume,a[j].prenume==0) | ~ ^ | ) 23 | { | ~ ratc2.cpp:34:5: error: expected primary-expression before ‘}’ token 34 | } | ^ ratc2.cpp:19:13: warning: unused variable ‘ok’ [-Wunused-variable] 19 | int ok=0; | ^~ ratc2.cpp:35:5: error: ‘sortare’ was not declared in this scope 35 | sortare(m,a); | ^~~~~~~ ratc2.cpp: At global scope: ratc2.cpp:49:20: error: ‘persoan’ has not been declared 49 | void sortare(int n,persoan a[]) | ^~~~~~~ ratc2.cpp: In function ‘void sortare(int, int*)’: ratc2.cpp:53:21: error: request for member ‘b’ in ‘*(a + ((sizetype)(((long unsigned int)i) * 4)))’, which is of non-class type ‘int’ 53 | if(a[i].b<a[j].b) | ^ ratc2.cpp:53:28: error: request for member ‘b’ in ‘*(a + ((sizetype)(((long unsigned int)j) * 4)))’, which is of non-class type ‘int’ 53 | if(a[i].b<a[j].b) | ^ ratc2.cpp:55:26: error: request for member ‘b’ in ‘*(a + ((sizetype)(((long unsigned int)i) * 4)))’, which is of non-class type ‘int’ 55 | else if(a[i].b==a[j].b && strcmp(a[i].nume,a[j].nume)>0) | ^ ratc2.cpp:55:34: error: request for member ‘b’ in ‘*(a + ((sizetype)(((long unsigned int)j) * 4)))’, which is of non-class type ‘int’ 55 | else if(a[i].b==a[j].b && strcmp(a[i].nume,a[j].nume)>0) | ^ ratc2.cpp:55:51: error: request for member ‘nume’ in ‘*(a + ((sizetype)(((long unsigned int)i) * 4)))’, which is of non-class type ‘int’ 55 | else if(a[i].b==a[j].b && strcmp(a[i].nume,a[j].nume)>0) | ^~~~ ratc2.cpp:55:61: error: request for member ‘nume’ in ‘*(a + ((sizetype)(((long unsigned int)j) * 4)))’, which is of non-class type ‘int’ 55 | else if(a[i].b==a[j].b && strcmp(a[i].nume,a[j].nume)>0) | ^~~~ ratc2.cpp:57:10: error: ‘i’ was not declared in this scope 57 | if(a[i].b==a[j].b && strcmp(a[i].nume,a[j].nume)==0 && strcmp(a[i].prenume,a[j].prenume)==0) | ^ ratc2.cpp:57:18: error: ‘j’ was not declared in this scope 57 | if(a[i].b==a[j].b && strcmp(a[i].nume,a[j].nume)==0 && strcmp(a[i].prenume,a[j].prenume)==0) | ^ ratc2.cpp: In function ‘int main()’: ratc2.cpp:79:16: error: invalid conversion from ‘persoana*’ to ‘int’ [-fpermissive] 79 | citire(n,p,a); | ^ | | | persoana* ratc2.cpp:79:16: error: cannot bind rvalue ‘(int)((persoana*)(& a))’ to ‘int&’ ratc2.cpp:10:32: note: in passing argument 3 of ‘void citire(int&, int&, int&, persoana*)’ 10 | void citire( int &n,int&m,int &p,persoana a[]) | ~~~~~^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema RATC2 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ă.