#633
Se dă un șir cu n elemente, numere naturale. Determinați diferența în valoare absolută dintre numărul de valori pare din șir și numărul de valori impare din șir.
| Problema | Paritate1 | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64658534 | Utilizator | |
| Fișier | paritate1.cpp | Dimensiune | 301 B |
| Data încărcării | 21 Mai 2026, 01:43 | Scor/rezultat | Eroare de compilare |
paritate1.cpp: In function ‘int main()’: paritate1.cpp:6:8: error: ‘i’ was not declared in this scope 6 | {int v[i],n,d=0,q=0,p=0; | ^ paritate1.cpp:9:11: error: ‘v’ was not declared in this scope 9 | cin>>v[i]; | ^ paritate1.cpp:12:9: error: ‘v’ was not declared in this scope 12 | if(v[i]%2==0) | ^ paritate1.cpp:18:16: error: no match for ‘operator=’ (operand types are ‘std::basic_ostream<char>’ and ‘int’) 18 | cout<<d=p-q; | ^ In file included from /usr/include/c++/13/iostream:41, from paritate1.cpp:1: /usr/include/c++/13/ostream:449:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator=(std::basic_ostream<_CharT, _Traits>&&) [with _CharT = char; _Traits = std::char_traits<char>]’ 449 | operator=(basic_ostream&& __rhs) | ^~~~~~~~ /usr/include/c++/13/ostream:449:33: note: no known conversion for argument 1 from ‘int’ to ‘std::basic_ostream<char>&&’ 449 | operator=(basic_ostream&& __rhs) | ~~~~~~~~~~~~~~~~^~~~~ paritate1.cpp:20:16: error: no match for ‘operator=’ (operand types are ‘std::basic_ostream<char>’ and ‘int’) 20 | cout<<d=q-p; | ^ /usr/include/c++/13/ostream:449:7: note: candidate: ‘std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator=(std::basic_ostream<_CharT, _Traits>&&) [with _CharT = char; _Traits = std::char_traits<char>]’ 449 | operator=(basic_ostream&& __rhs) | ^~~~~~~~ /usr/include/c++/13/ostream:449:33: note: no known conversion for argument 1 from ‘int’ to ‘std::basic_ostream<char>&&’ 449 | operator=(basic_ostream&& __rhs) | ~~~~~~~~~~~~~~~~^~~~~ paritate1.cpp:19:2: warning: this ‘else’ clause does not guard... [-Wmisleading-indentation] 19 | else | ^~~~ paritate1.cpp:20:18: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘else’ 20 | cout<<d=q-p; | ^ paritate1.cpp:20:18: error: expected ‘}’ at end of input paritate1.cpp:6:1: note: to match this ‘{’ 6 | {int v[i],n,d=0,q=0,p=0; | ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Paritate1 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ă.