#752
BiArbore
Se consideră un arbore binar alocat dinamic în care nodurile memorează numere naturale nenule. Să se determine valorile memorate în descendenții direcți ai rădăcinii arborelui.
Problema | BiArbore | Operații I/O |
biarbore.in /biarbore.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #29592630 | Utilizator | |
Fișier | biarbore.cpp | Dimensiune | 734 B |
Data încărcării | 11 Mai 2021, 10:20 | Scor / rezultat | Eroare de compilare |
biarbore.cpp:1:20: warning: extra tokens at end of #include directive [enabled by default] #include <fstream> using namespace std; ifstream f("biarbore.in"); ofstream g("biarbore.out"); struct nod {int info; nod *st,*dr; }; nod *rad; void creare(nod *&rad) { int x; f>>x; if(x==0) rad=NULL; else {rad=new (nod); rad->info=x; creare(rad->st); creare(rad->dr); } } void afis_rsd(nod*rad) {if(rad!=NULL) { g<<rad->info<<' '; afis_rsd(rad->st); afis_rsd(rad->dr); } } void afis_srd(nod*rad) {if(rad!=NULL) { afis_srd(rad->st); g<<rad->info<<' '; afis_srd(rad->dr); } } void afis_sdr(nod*rad) {if(rad!=NULL) { afis_sdr(rad->st); afis_sdr(rad->dr); g<<rad->info<<' '; } } int main() { creare(rad); //afis_rsd(rad); if(rad->st!=NULL) g<<rad->st->info<<' '; else g<<"0 "; if(rad->dr!=NULL) g<<rad->dr->info; else g<<"0 "; return 0; } ^ biarbore.cpp:1:314: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix] #include <fstream> using namespace std; ifstream f("biarbore.in"); ofstream g("biarbore.out"); struct nod {int info; nod *st,*dr; }; nod *rad; void creare(nod *&rad) { int x; f>>x; if(x==0) rad=NULL; else {rad=new (nod); rad->info=x; creare(rad->st); creare(rad->dr); } } void afis_rsd(nod*rad) {if(rad!=NULL) { g<<rad->info<<' '; afis_rsd(rad->st); afis_rsd(rad->dr); } } void afis_srd(nod*rad) {if(rad!=NULL) { afis_srd(rad->st); g<<rad->info<<' '; afis_srd(rad->dr); } } void afis_sdr(nod*rad) {if(rad!=NULL) { afis_sdr(rad->st); afis_sdr(rad->dr); g<<rad->info<<' '; } } int main() { creare(rad); //afis_rsd(rad); if(rad->st!=NULL) g<<rad->st->info<<' '; else g<<"0 "; if(rad->dr!=NULL) g<<rad->dr->info; else g<<"0 "; return 0; } ^ biarbore.cpp:1:434: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix] #include <fstream> using namespace std; ifstream f("biarbore.in"); ofstream g("biarbore.out"); struct nod {int info; nod *st,*dr; }; nod *rad; void creare(nod *&rad) { int x; f>>x; if(x==0) rad=NULL; else {rad=new (nod); rad->info=x; creare(rad->st); creare(rad->dr); } } void afis_rsd(nod*rad) {if(rad!=NULL) { g<<rad->info<<' '; afis_rsd(rad->st); afis_rsd(rad->dr); } } void afis_srd(nod*rad) {if(rad!=NULL) { afis_srd(rad->st); g<<rad->info<<' '; afis_srd(rad->dr); } } void afis_sdr(nod*rad) {if(rad!=NULL) { afis_sdr(rad->st); afis_sdr(rad->dr); g<<rad->info<<' '; } } int main() { creare(rad); //afis_rsd(rad); if(rad->st!=NULL) g<<rad->st->info<<' '; else g<<"0 "; if(rad->dr!=NULL) g<<rad->dr->info; else g<<"0 "; return 0; } ^ biarbore.cpp:1:445: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix] #include <fstream> using namespace std; ifstream f("biarbore.in"); ofstream g("biarbore.out"); struct nod {int info; nod *st,*dr; }; nod *rad; void creare(nod *&rad) { int x; f>>x; if(x==0) rad=NULL; else {rad=new (nod); rad->info=x; creare(rad->st); creare(rad->dr); } } void afis_rsd(nod*rad) {if(rad!=NULL) { g<<rad->info<<' '; afis_rsd(rad->st); afis_rsd(rad->dr); } } void afis_srd(nod*rad) {if(rad!=NULL) { afis_srd(rad->st); g<<rad->info<<' '; afis_srd(rad->dr); } } void afis_sdr(nod*rad) {if(rad!=NULL) { afis_sdr(rad->st); afis_sdr(rad->dr); g<<rad->info<<' '; } } int main() { creare(rad); //afis_rsd(rad); if(rad->st!=NULL) g<<rad->st->info<<' '; else g<<"0 "; if(rad->dr!=NULL) g<<rad->dr->info; else g<<"0 "; return 0; } ^ biarbore.cpp:1:554: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix] #include <fstream> using namespace std; ifstream f("biarbore.in"); ofstream g("biarbore.out"); struct nod {int info; nod *st,*dr; }; nod *rad; void creare(nod *&rad) { int x; f>>x; if(x==0) rad=NULL; else {rad=new (nod); rad->info=x; creare(rad->st); creare(rad->dr); } } void afis_rsd(nod*rad) {if(rad!=NULL) { g<<rad->info<<' '; afis_rsd(rad->st); afis_rsd(rad->dr); } } void afis_srd(nod*rad) {if(rad!=NULL) { afis_srd(rad->st); g<<rad->info<<' '; afis_srd(rad->dr); } } void afis_sdr(nod*rad) {if(rad!=NULL) { afis_sdr(rad->st); afis_sdr(rad->dr); g<<rad->info<<' '; } } int main() { creare(rad); //afis_rsd(rad); if(rad->st!=NULL) g<<rad->st->info<<' '; else g<<"0 "; if(rad->dr!=NULL) g<<rad->dr->info; else g<<"0 "; return 0; } ^ biarbore.cpp:1:653: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix] #include <fstream> using namespace std; ifstream f("biarbore.in"); ofstream g("biarbore.out"); struct nod {int info; nod *st,*dr; }; nod *rad; void creare(nod *&rad) { int x; f>>x; if(x==0) rad=NULL; else {rad=new (nod); rad->info=x; creare(rad->st); creare(rad->dr); } } void afis_rsd(nod*rad) {if(rad!=NULL) { g<<rad->info<<' '; afis_rsd(rad->st); afis_rsd(rad->dr); } } void afis_srd(nod*rad) {if(rad!=NULL) { afis_srd(rad->st); g<<rad->info<<' '; afis_srd(rad->dr); } } void afis_sdr(nod*rad) {if(rad!=NULL) { afis_sdr(rad->st); afis_sdr(rad->dr); g<<rad->info<<' '; } } int main() { creare(rad); //afis_rsd(rad); if(rad->st!=NULL) g<<rad->st->info<<' '; else g<<"0 "; if(rad->dr!=NULL) g<<rad->dr->info; else g<<"0 "; return 0; } ^ biarbore.cpp:1:693: warning: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wliteral-suffix] #include <fstream> using namespace std; ifstream f("biarbore.in"); ofstream g("biarbore.out"); struct nod {int info; nod *st,*dr; }; nod *rad; void creare(nod *&rad) { int x; f>>x; if(x==0) rad=NULL; else {rad=new (nod); rad->info=x; creare(rad->st); creare(rad->dr); } } void afis_rsd(nod*rad) {if(rad!=NULL) { g<<rad->info<<' '; afis_rsd(rad->st); afis_rsd(rad->dr); } } void afis_srd(nod*rad) {if(rad!=NULL) { afis_srd(rad->st); g<<rad->info<<' '; afis_srd(rad->dr); } } void afis_sdr(nod*rad) {if(rad!=NULL) { afis_sdr(rad->st); afis_sdr(rad->dr); g<<rad->info<<' '; } } int main() { creare(rad); //afis_rsd(rad); if(rad->st!=NULL) g<<rad->st->info<<' '; else g<<"0 "; if(rad->dr!=NULL) g<<rad->dr->info; else g<<"0 "; return 0; } ^ /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 2 has invalid symbol index 2 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 3 has invalid symbol index 2 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 4 has invalid symbol index 11 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 5 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 6 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 7 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 8 has invalid symbol index 12 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 9 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 10 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 11 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 12 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 13 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 14 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 15 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 16 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 17 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 18 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 19 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 20 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 21 has invalid symbol index 22 /usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_line): relocation 0 has invalid symbol index 2 /usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/crt1.o: In function \`_start': (.text+0x18): undefined reference to \`main' collect2: error: ld returned 1 exit status
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema BiArbore 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ă.