#109
Să se scrie un program care citeşte de la tastatură un număr natural şi verifică dacă numărul este par sau impar.
| Problema | Paritate | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64823450 | Utilizator | |
| Fișier | paritate.cpp | Dimensiune | 129 B |
| Data încărcării | 03 Iunie 2026, 19:28 | Scor/rezultat | Eroare de compilare |
paritate.cpp: In function ‘int main()’: paritate.cpp:6:1: error: ‘cin’ was not declared in this scope; did you mean ‘std::cin’? 6 | cin>>n; | ^~~ | std::cin In file included from paritate.cpp:1: /usr/include/c++/13/iostream:62:18: note: ‘std::cin’ declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ paritate.cpp:7:5: error: lvalue required as left operand of assignment 7 | if(n%2=0); | ~^~ paritate.cpp:7:1: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation] 7 | if(n%2=0); | ^~ paritate.cpp:8:1: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’ 8 | {cout<<par} | ^ paritate.cpp:8:2: error: ‘cout’ was not declared in this scope; did you mean ‘std::cout’? 8 | {cout<<par} | ^~~~ | std::cout /usr/include/c++/13/iostream:63:18: note: ‘std::cout’ declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ paritate.cpp:8:8: error: ‘par’ was not declared in this scope 8 | {cout<<par} | ^~~ paritate.cpp:9:1: error: ‘else’ without a previous ‘if’ 9 | else | ^~~~ paritate.cpp:10:1: error: ‘cout’ was not declared in this scope; did you mean ‘std::cout’? 10 | cout<<impar} | ^~~~ | std::cout /usr/include/c++/13/iostream:63:18: note: ‘std::cout’ declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ paritate.cpp:10:7: error: ‘impar’ was not declared in this scope 10 | cout<<impar} | ^~~~~ paritate.cpp: At global scope: paritate.cpp:11:1: error: expected unqualified-id before ‘{’ token 11 | { | ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Paritate 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ă.