#4165
Să se scrie o funcție C++ care inserează pe poziția k un nou nod cu informația x.
Problema de interviu
| Problema | FInserareKX | Operații I/O |
finserarekx.in/finserarekx.out
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64506133 | Utilizator | |
| Fișier | finserarekx.cpp | Dimensiune | 464 B |
| Data încărcării | 11 Mai 2026, 17:57 | Scor/rezultat | Eroare de compilare |
finserarekx.cpp: In function ‘void FInserareKX(Nod*&, int, int)’: finserarekx.cpp:16:17: error: conversion from ‘Nod*’ to non-scalar type ‘Nod’ requested 16 | Nod ner = new Nod; | ^~~~~~~ finserarekx.cpp:17:11: error: base operand of ‘->’ has non-pointer type ‘Nod’ 17 | ner -> info = x; | ^~ finserarekx.cpp:18:11: error: base operand of ‘->’ has non-pointer type ‘Nod’ 18 | ner -> leg = head; | ^~ finserarekx.cpp:19:14: error: cannot convert ‘Nod’ to ‘Nod*’ in assignment 19 | head = ner; | ^~~ | | | Nod finserarekx.cpp:22:14: error: conversion from ‘Nod*’ to non-scalar type ‘Nod’ requested 22 | Nod q = head; | ^~~~ finserarekx.cpp:23:20: error: base operand of ‘->’ has non-pointer type ‘Nod’ 23 | while(k>2 && q -> leg !+ NULL){ | ^~ finserarekx.cpp:23:26: error: expected ‘)’ before ‘!’ token 23 | while(k>2 && q -> leg !+ NULL){ | ~ ^~ | ) finserarekx.cpp:23:30: warning: converting NULL to non-pointer type [-Wconversion-null] 23 | while(k>2 && q -> leg !+ NULL){ | ^~~~ finserarekx.cpp:23:34: error: expected ‘;’ before ‘)’ token 23 | while(k>2 && q -> leg !+ NULL){ | ^ finserarekx.cpp:23:27: warning: statement has no effect [-Wunused-value] 23 | while(k>2 && q -> leg !+ NULL){ | ^ finserarekx.cpp:29:22: error: base operand of ‘->’ has non-pointer type ‘Nod’ 29 | noder -> leg = q -> led; | ^~ finserarekx.cpp:30:7: error: base operand of ‘->’ has non-pointer type ‘Nod’ 30 | q -> leg = noder; | ^~ finserarekx.cpp:33:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 33 | int main() | ^~ finserarekx.cpp:33:9: note: remove parentheses to default-initialize a variable 33 | int main() | ^~ | -- finserarekx.cpp:33:9: note: or replace parentheses with braces to value-initialize a variable finserarekx.cpp:34:1: error: a function-definition is not allowed here before ‘{’ token 34 | { | ^ finserarekx.cpp:57:2: error: expected ‘}’ at end of input 57 | } | ^ finserarekx.cpp:10:44: note: to match this ‘{’ 10 | void FInserareKX(Nod * &head, int k, int x){ | ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema FInserareKX 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ă.