#497
Majoritar
Se dă un vector cu n
elemente, numere naturale. Verificați dacă vectorul are un element majoritar. Numim element majoritar o valoare pentru care numărul de apariții în vector este mai mare decât n/2
.
Problema | Majoritar | Operații I/O | tastatură/ecran |
---|---|---|---|
Limita timp | 0.25 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #50105430 | Utilizator | |
Fișier | majoritar.cpp | Dimensiune | 1.13 KB |
Data încărcării | 27 Martie 2024, 10:49 | Scor / rezultat | Eroare de compilare |
majoritar.cpp:2:1: error: too many decimal points in number 10.01.2020 ^ majoritar.cpp:3:1: error: stray '\304' in program Informatică ^ majoritar.cpp:3:1: error: stray '\203' in program majoritar.cpp:5:1: error: stray '\304' in program a fost răspuns ^ majoritar.cpp:5:1: error: stray '\203' in program majoritar.cpp:6:1: error: stray '\310' in program Cerința ^ majoritar.cpp:6:1: error: stray '\233' in program majoritar.cpp:7:1: error: stray '\304' in program Se dă un vector cu n elemente, numere naturale. Verificați dacă vectorul are un element majoritar. Numim element majoritar o valoare pentru care numărul de apariții în vector este mai mare decât n/2. ^ majoritar.cpp:7:1: error: stray '\203' in program majoritar.cpp:7:1: error: stray '\310' in program majoritar.cpp:7:1: error: stray '\233' in program majoritar.cpp:7:1: error: stray '\304' in program majoritar.cpp:7:1: error: stray '\203' in program majoritar.cpp:7:1: error: stray '\304' in program majoritar.cpp:7:1: error: stray '\203' in program majoritar.cpp:7:1: error: stray '\310' in program majoritar.cpp:7:1: error: stray '\233' in program majoritar.cpp:7:1: error: stray '\303' in program majoritar.cpp:7:1: error: stray '\256' in program majoritar.cpp:7:1: error: stray '\303' in program majoritar.cpp:7:1: error: stray '\242' in program majoritar.cpp:12:1: error: stray '\310' in program Programul citește de la tastatură numărul n, iar apoi n numere naturale, separate prin spații, reprezentând elementele vectorului. ^ majoritar.cpp:12:1: error: stray '\231' in program majoritar.cpp:12:1: error: stray '\304' in program majoritar.cpp:12:1: error: stray '\203' in program majoritar.cpp:12:1: error: stray '\304' in program majoritar.cpp:12:1: error: stray '\203' in program majoritar.cpp:12:1: error: stray '\310' in program majoritar.cpp:12:1: error: stray '\233' in program majoritar.cpp:12:1: error: stray '\303' in program majoritar.cpp:12:1: error: stray '\242' in program majoritar.cpp:15:1: error: stray '\310' in program Date de ieșire ^ majoritar.cpp:15:1: error: stray '\231' in program majoritar.cpp:17:1: error: stray '\310' in program Programul va afișa pe ecran mesajul NU, dacă vectorul nu are un element majoritar, respectiv DA X, dacă vectorul are un element majoritar, unde X este valoarea acestuia. ^ majoritar.cpp:17:1: error: stray '\231' in program majoritar.cpp:17:1: error: stray '\304' in program majoritar.cpp:17:1: error: stray '\203' in program majoritar.cpp:17:1: error: stray '\304' in program majoritar.cpp:17:1: error: stray '\203' in program majoritar.cpp:20:1: error: stray '\310' in program Restricții și precizări ^ majoritar.cpp:20:1: error: stray '\233' in program majoritar.cpp:20:1: error: stray '\310' in program majoritar.cpp:20:1: error: stray '\231' in program majoritar.cpp:20:1: error: stray '\304' in program majoritar.cpp:20:1: error: stray '\203' in program majoritar.cpp:22:1: error: stray '\342' in program 1 ≤ n ≤ 100.000 ^ majoritar.cpp:22:1: error: stray '\211' in program majoritar.cpp:22:1: error: stray '\244' in program majoritar.cpp:22:1: error: stray '\342' in program majoritar.cpp:22:1: error: stray '\211' in program majoritar.cpp:22:1: error: stray '\244' in program majoritar.cpp:24:1: error: stray '\303' in program cele n numere citite vor fi mai mici decât 1.000.000.000 ^ majoritar.cpp:24:1: error: stray '\242' in program majoritar.cpp:24:45: error: too many decimal points in number cele n numere citite vor fi mai mici decât 1.000.000.000 ^ majoritar.cpp:28:9: error: #include expects "FILENAME" or <FILENAME> #include ^ majoritar.cpp:1:1: error: 'Ovidiu0144' does not name a type Ovidiu0144 ^ majoritar.cpp: In function 'int main()': majoritar.cpp:40:1: error: 'cin' was not declared in this scope cin>>n; ^ majoritar.cpp:60:10: error: 'cout' was not declared in this scope if(ok==1)cout<<"NU"; ^ majoritar.cpp:62:6: error: 'cout' was not declared in this scope else cout<<"DA "<} ^ majoritar.cpp:62:18: error: expected primary-expression before '}' token else cout<<"DA "<} ^ majoritar.cpp:62:18: error: expected ';' before '}' token
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Majoritar 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ă.