#67
Să se scrie o funcție C++ care verifică dacă un număr natural transmis ca parametru este aproape prim.
| Problema | AproapePrim | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64719471 | Utilizator | |
| Fișier | aproapeprim.cpp | Dimensiune | 381 B |
| Data încărcării | 25 Mai 2026, 22:16 | Scor/rezultat | Eroare de compilare |
aproapeprim.cpp: In function ‘int a_prim(unsigned int)’: aproapeprim.cpp:16:48: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare] 16 | if(prim1 && prim2 && d != q) | ~~^~~~ aproapeprim.cpp:22:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 22 | int main(){ | ^~ aproapeprim.cpp:22:9: note: remove parentheses to default-initialize a variable 22 | int main(){ | ^~ | -- aproapeprim.cpp:22:9: note: or replace parentheses with braces to value-initialize a variable aproapeprim.cpp:22:11: error: a function-definition is not allowed here before ‘{’ token 22 | int main(){ | ^ aproapeprim.cpp:27:2: error: expected ‘}’ at end of input 27 | } | ^ aproapeprim.cpp:5:1: note: to match this ‘{’ 5 | { int d1 = 0, d2 = 0, nr = 0; | ^ aproapeprim.cpp:5:13: warning: unused variable ‘d1’ [-Wunused-variable] 5 | { int d1 = 0, d2 = 0, nr = 0; | ^~ aproapeprim.cpp:5:21: warning: unused variable ‘d2’ [-Wunused-variable] 5 | { int d1 = 0, d2 = 0, nr = 0; | ^~ aproapeprim.cpp:5:29: warning: unused variable ‘nr’ [-Wunused-variable] 5 | { int d1 = 0, d2 = 0, nr = 0; | ^~
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema AproapePrim face parte din a doua categorie. Pentru aceste probleme se folosește un program suport, furnizat de propunătorul problemei. 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ă.