Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream fin("biarbore.in");
- ofstream fout("biarbore.out");
- struct nod
- {
- int valoare;
- nod *left, *right;
- };
- nod *radacina;
- void citire(nod *&nodeParam)
- {
- nod *newNode = new nod;
- int nr;
- if(fin >> nr && nr != 0)
- {
- // cout << "[!!]: Am citit: " << nr << "\n";
- newNode->valoare = nr;
- newNode->left = NULL;
- newNode->right = NULL;
- if(nodeParam == NULL)
- nodeParam = newNode;
- citire(newNode->left);
- citire(newNode->right);
- }
- }
- void parcurgere(nod *nodeCrt)
- {
- if(nodeCrt != NULL)
- {
- // cout << "Nodul: " << nodeCrt->valoare << "\n";
- // cout << "[!!]: Left Child: ";
- parcurgere(nodeCrt->left);
- // cout << "[!!]: Right Child: ";
- parcurgere(nodeCrt->right);
- // cout << "\n\n";
- }
- }
- int main()
- {
- citire(radacina);
- // parcurgere(radacina);
- fout << radacina->left->valoare << " " << radacina->right->valoare;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement