#1149
ExistaPrimeDivImp
Se dă un şir cu n
elemente, numere naturale. Folosind metoda Divide et Impera să se verifice dacă în șir există elemente prime.
Problema | ExistaPrimeDivImp | Operații I/O | tastatură/ecran |
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #50149755 | Utilizator | |
Fișier | existaprimedivimp.cpp | Dimensiune | 1.22 KB |
Data încărcării | 28 Martie 2024, 18:20 | Scor / rezultat | Eroare de compilare |
existaprimedivimp.cpp: In function 'bool is_prime(int)': existaprimedivimp.cpp:5:34: error: 'sqrt' was not declared in this scope for (int i = 2; i <= sqrt(num); ++i) { ^ existaprimedivimp.cpp: At global scope: existaprimedivimp.cpp:13:22: error: 'vector' does not name a type bool has_prime(const vector<int>& arr, int start, int end) { ^ existaprimedivimp.cpp:13:22: error: ISO C++ forbids declaration of 'parameter' with no type [-fpermissive] existaprimedivimp.cpp:13:28: error: expected ',' or '...' before '<' token bool has_prime(const vector<int>& arr, int start, int end) { ^ existaprimedivimp.cpp: In function 'bool has_prime(int)': existaprimedivimp.cpp:14:9: error: 'start' was not declared in this scope if (start > end) { ^ existaprimedivimp.cpp:14:17: error: 'end' was not declared in this scope if (start > end) { ^ existaprimedivimp.cpp:17:9: error: 'start' was not declared in this scope if (start == end) { // Cazul de bază: intervalul conține un singur element ^ existaprimedivimp.cpp:17:18: error: 'end' was not declared in this scope if (start == end) { // Cazul de bază: intervalul conține un singur element ^ existaprimedivimp.cpp:18:25: error: 'arr' was not declared in this scope return is_prime(arr[start]); // Verificăm dacă elementul este prim ^ existaprimedivimp.cpp:21:16: error: 'start' was not declared in this scope int mid = (start + end) / 2; ^ existaprimedivimp.cpp:21:24: error: 'end' was not declared in this scope int mid = (start + end) / 2; ^ existaprimedivimp.cpp:22:22: error: 'arr' was not declared in this scope return has_prime(arr, start, mid) || has_prime(arr, mid + 1, end); // Verificăm recursiv cele două jumătăți ale intervalului ^ existaprimedivimp.cpp: In function 'int main()': existaprimedivimp.cpp:27:5: error: 'cout' was not declared in this scope cout << "Introduceți lungimea șirului: "; ^ existaprimedivimp.cpp:28:5: error: 'cin' was not declared in this scope cin >> n; ^ existaprimedivimp.cpp:30:5: error: 'vector' was not declared in this scope vector<int> arr(n); ^ existaprimedivimp.cpp:30:12: error: expected primary-expression before 'int' vector<int> arr(n); ^ existaprimedivimp.cpp:30:12: error: expected ';' before 'int' existaprimedivimp.cpp:33:16: error: 'arr' was not declared in this scope cin >> arr[i]; ^ existaprimedivimp.cpp:36:19: error: 'arr' was not declared in this scope if (has_prime(arr, 0, n - 1)) { ^ existaprimedivimp.cpp:37:66: error: 'endl' was not declared in this scope cout << "Șirul conține cel puțin un element prim." << endl; ^ existaprimedivimp.cpp:39:62: error: 'endl' was not declared in this scope cout << "Șirul nu conține niciun element prim." << endl; ^ existaprimedivimp.cpp: In function 'bool has_prime(int)': existaprimedivimp.cpp:23:1: warning: control reaches end of non-void function [-Wreturn-type] } ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema ExistaPrimeDivImp 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ă.