#14
Primalitate
C++
Să se scrie o funcție C++ care verifică dacă un număr natural transmis ca parametru este prim.
Problema | Primalitate | Operații I/O |
![]() |
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #31546814 | Utilizator | |
Fișier | primalitate.cpp | Dimensiune | 281 B |
Data încărcării | 16 Octombrie 2021, 20:24 | Scor / rezultat | Eroare de compilare |
primalitate.cpp: In function 'int prim(int)': primalitate.cpp:8:25: error: expression list treated as compound expression in initializer [-fpermissive] for(int i=2, pow(i,2)<=a, i++) ^ primalitate.cpp:8:25: warning: left operand of comma operator has no effect [-Wunused-value] primalitate.cpp:8:26: error: expected ';' before '<=' token for(int i=2, pow(i,2)<=a, i++) ^ primalitate.cpp:8:26: error: expected primary-expression before '<=' token primalitate.cpp:8:34: error: expected ';' before ')' token for(int i=2, pow(i,2)<=a, i++) ^ primalitate.cpp:10:29: error: expression list treated as compound expression in initializer [-fpermissive] for(int j=1, pow(j,2)<=a;j++) ^ primalitate.cpp:10:29: warning: left operand of comma operator has no effect [-Wunused-value] primalitate.cpp:10:30: error: expected ';' before '<=' token for(int j=1, pow(j,2)<=a;j++) ^ primalitate.cpp:10:30: error: expected primary-expression before '<=' token primalitate.cpp:10:22: warning: unused variable 'pow' [-Wunused-variable] for(int j=1, pow(j,2)<=a;j++) ^ primalitate.cpp:8:18: warning: unused variable 'pow' [-Wunused-variable] for(int i=2, pow(i,2)<=a, i++) ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Primalitate 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ă.