#4173
FLdiCauta
C++
Să se scrie o funcție C++ care va returna informația reținută în al k
-lea nod, parcurgând lista de la stânga la dreapta dacă k > 0
sau al -k
-lea nod, parcurgând lista de la dreapta la stânga dacă k < 0
.
Problema | FLdiCauta | Operații I/O |
![]() fldicauta.in /fldicauta.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #57201041 | Utilizator | |
Fișier | fldicauta.cpp | Dimensiune | 1.06 KB |
Data încărcării | 20 Martie 2025, 07:56 | Scor / rezultat | Eroare de compilare |
fldicauta.cpp:18:8: error: redefinition of 'struct nod' struct nod { ^ fldicauta.cpp:4:8: error: previous definition of 'struct nod' struct nod ^ fldicauta.cpp: In function 'int main()': fldicauta.cpp:24:34: error: no matching function for call to 'nod::nod(<brace-enclosed initializer list>)' nod* d = new nod{5,NULL, NULL}; ^ fldicauta.cpp:24:34: note: candidates are: fldicauta.cpp:8:5: note: nod::nod() nod() ^ fldicauta.cpp:8:5: note: candidate expects 0 arguments, 3 provided fldicauta.cpp:4:8: note: constexpr nod::nod(const nod&) struct nod ^ fldicauta.cpp:4:8: note: candidate expects 1 argument, 3 provided fldicauta.cpp:4:8: note: constexpr nod::nod(nod&&) fldicauta.cpp:4:8: note: candidate expects 1 argument, 3 provided fldicauta.cpp:25:32: error: no matching function for call to 'nod::nod(<brace-enclosed initializer list>)' nod* f = new nod{3, d, NULL}; ^ fldicauta.cpp:25:32: note: candidates are: fldicauta.cpp:8:5: note: nod::nod() nod() ^ fldicauta.cpp:8:5: note: candidate expects 0 arguments, 3 provided fldicauta.cpp:4:8: note: constexpr nod::nod(const nod&) struct nod ^ fldicauta.cpp:4:8: note: candidate expects 1 argument, 3 provided fldicauta.cpp:4:8: note: constexpr nod::nod(nod&&) fldicauta.cpp:4:8: note: candidate expects 1 argument, 3 provided fldicauta.cpp:26:32: error: no matching function for call to 'nod::nod(<brace-enclosed initializer list>)' nod* g = new nod{6, f, NULL}; ^ fldicauta.cpp:26:32: note: candidates are: fldicauta.cpp:8:5: note: nod::nod() nod() ^ fldicauta.cpp:8:5: note: candidate expects 0 arguments, 3 provided fldicauta.cpp:4:8: note: constexpr nod::nod(const nod&) struct nod ^ fldicauta.cpp:4:8: note: candidate expects 1 argument, 3 provided fldicauta.cpp:4:8: note: constexpr nod::nod(nod&&) fldicauta.cpp:4:8: note: candidate expects 1 argument, 3 provided fldicauta.cpp:27:32: error: no matching function for call to 'nod::nod(<brace-enclosed initializer list>)' nod* j = new nod{8, g, NULL}; ^ fldicauta.cpp:27:32: note: candidates are: fldicauta.cpp:8:5: note: nod::nod() nod() ^ fldicauta.cpp:8:5: note: candidate expects 0 arguments, 3 provided fldicauta.cpp:4:8: note: constexpr nod::nod(const nod&) struct nod ^ fldicauta.cpp:4:8: note: candidate expects 1 argument, 3 provided fldicauta.cpp:4:8: note: constexpr nod::nod(nod&&) fldicauta.cpp:4:8: note: candidate expects 1 argument, 3 provided fldicauta.cpp:28:8: error: 'struct nod' has no member named 'c' d->c = f; ^ fldicauta.cpp:29:8: error: 'struct nod' has no member named 'c' f->c = g; ^ fldicauta.cpp:30:8: error: 'struct nod' has no member named 'c' g->c = j; ^ fldicauta.cpp:31:8: error: 'struct nod' has no member named 'b' f->b = d; ^ fldicauta.cpp:32:8: error: 'struct nod' has no member named 'b' g->b = f; ^ fldicauta.cpp:33:8: error: 'struct nod' has no member named 'b' j->b = g; ^ fldicauta.cpp:37:9: error: conflicting declaration 'int g' int g = 1; ^ fldicauta.cpp:26:10: error: 'g' has a previous declaration as 'nod* g' nod* g = new nod{6, f, NULL}; ^ fldicauta.cpp:41:33: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] while (h != NULL && g < k) { ^ fldicauta.cpp:42:20: error: 'struct nod' has no member named 'c' h = h->c; ^ fldicauta.cpp:46:51: error: 'struct nod' has no member named 'a' cout << "Rezultatul cautarii: " << h->a << endl; ^ fldicauta.cpp:48:51: error: 'struct nod' has no member named 'a' cout << "Rezultatul cautarii: " << e->a << endl; ^ fldicauta.cpp:53:11: error: invalid conversion from 'int' to 'nod*' [-fpermissive] g = 1; ^ fldicauta.cpp:54:33: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] while (h != NULL && g < i) { ^ fldicauta.cpp:55:20: error: 'struct nod' has no member named 'b' h = h->b; ^ fldicauta.cpp:59:51: error: 'struct nod' has no member named 'a' cout << "Rezultatul cautarii: " << h->a << endl; ^ fldicauta.cpp:61:51: error: 'struct nod' has no member named 'a' cout << "Rezultatul cautarii: " << d->a << endl; ^ fldicauta.cpp: In function 'int main()': fldicauta.cpp:69:5: error: redefinition of 'int main()' int main() ^ fldicauta.cpp:23:5: error: 'int main()' previously defined here int main() { ^ fldicauta.cpp:90:37: error: 'FLdiCauta' was not declared in this scope fout << FLdiCauta(prim, ultim, k) << "\n"; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema FLdiCauta 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ă.