#2802
Se citește de la tastatură numărul n și un număr p cu valoarea 1 sau 2 și apoi n șiruri de tip nume prenume media1 media2 media3 separate prin spații.
Pentru p=1, se va afișa numărul elevilor care au media generală mai mare sau egală decât media clasei.
Pentru p=2, se va afișa pe primul rând media clasei și pe următoarele n rânduri, numele, prenumele și media generală a fiecărui elev, separate printr-un singur spațiu, sortat descrescător după medie; la medii egale se sortează crescător după nume, iar la nume egale crescător după prenume.
| Problema | Clasa | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.01 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64795761 | Utilizator | |
| Fișier | clasa.cpp | Dimensiune | 774 B |
| Data încărcării | 01 Iunie 2026, 21:59 | Scor/rezultat | Eroare de compilare |
clasa.cpp:9:2: error: ‘Elev’ does not name a type; did you mean ‘elev’? 9 | Elev v[101]; | ^~~~ | elev clasa.cpp: In function ‘int main()’: clasa.cpp:13:7: error: ‘cin’ was not declared in this scope 13 | cin >> n >> p; | ^~~ clasa.cpp:14:11: error: ‘i’ was not declared in this scope 14 | for(i=1;i<=n;i++) | ^ clasa.cpp:15:12: error: ‘v’ was not declared in this scope 15 | cin>>v[i].nume>>v[i].prenume>>v[i].media1>>v[i].media2>>v[i].media3; | ^ clasa.cpp:16:7: error: ‘m’ was not declared in this scope 16 | m=(v[i].media1+v[i].media2+v[i].media3)/3; | ^ clasa.cpp:16:10: error: ‘v’ was not declared in this scope 16 | m=(v[i].media1+v[i].media2+v[i].media3)/3; | ^ clasa.cpp:16:12: error: ‘i’ was not declared in this scope 16 | m=(v[i].media1+v[i].media2+v[i].media3)/3; | ^ clasa.cpp:21:15: error: ‘nr’ was not declared in this scope; did you mean ‘n’? 21 | nr++; | ^~ | n clasa.cpp:19:11: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation] 19 | for(i=1;i<=n;i++) | ^~~ clasa.cpp:22:15: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’ 22 | cout<<nr; | ^~~~ clasa.cpp:22:15: error: ‘cout’ was not declared in this scope clasa.cpp:22:21: error: ‘nr’ was not declared in this scope; did you mean ‘n’? 22 | cout<<nr; | ^~ | n clasa.cpp:26:11: error: ‘cout’ was not declared in this scope 26 | cout<<mc; | ^~~~ clasa.cpp:26:17: error: ‘mc’ was not declared in this scope 26 | cout<<mc; | ^~ clasa.cpp:28:19: error: ‘j’ was not declared in this scope 28 | for(j=i+1;j>=n;j++) | ^ clasa.cpp:30:15: error: ‘swap’ was not declared in this scope 30 | swap(v[i],v[j]); | ^~~~ clasa.cpp:27:11: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation] 27 | for(i=1;i<=n;i++) | ^~~ clasa.cpp:31:15: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’ 31 | if(v[i].m==v[j].m) | ^~ clasa.cpp:31:28: error: ‘j’ was not declared in this scope 31 | if(v[i].m==v[j].m) | ^ clasa.cpp:32:18: error: ‘strcmp’ was not declared in this scope 32 | if(strcmp(v[i].nume | v[j].nume)>0) | ^~~~~~ clasa.cpp:1:1: note: ‘strcmp’ is defined in header ‘<cstring>’; did you forget to ‘#include <cstring>’? +++ |+#include <cstring> 1 | struct elev clasa.cpp:33:15: error: ‘swap’ was not declared in this scope 33 | swap(v[i]>v[j]); | ^~~~ clasa.cpp:32:15: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation] 32 | if(strcmp(v[i].nume | v[j].nume)>0) | ^~ clasa.cpp:33:31: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’ 33 | swap(v[i]>v[j]); | ^ clasa.cpp:33:31: error: expected ‘}’ at end of input clasa.cpp:25:7: note: to match this ‘{’ 25 | { | ^ clasa.cpp:33:31: error: expected ‘}’ at end of input 33 | swap(v[i]>v[j]); | ^ clasa.cpp:11:1: note: to match this ‘{’ 11 | { | ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Clasa 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ă.