Results 1 to 10 of 10

Thread: C++

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date: Mar:2018
    Location: pleven
    Posts: 6

    C++

    .

  2. #2
    Banned
    Join Date: Mar:2008
    Location: ( ͡ ͜ʖ ͡)
    Posts: 10,614
    ?

  3. #3
    Registered User
    Join Date: Mar:2018
    Location: pleven
    Posts: 6
    struct elemlist
    {
    int key;
    elemlist *next;
    } *start = NULL;

    //Strukturata za durvo
    struct elemtree
    {
    int key;
    elemtree *left;
    elemtree *right;
    int bal;
    } *root = NULL;

    //Izvejdane na spisuka
    void list()
    {
    if(start)
    {
    cout<<"\nList: ";
    elemlist *p = start;
    while(p)
    {
    cout<<p -> key<<" ";
    p = p -> next;
    }
    }
    else cout<<"\nEmpty List";
    cout<<"\n\n";
    system("pause");
    system("cls");
    }

    //Dobavqne na element v spisuka otnachalo
    void add_b(int n)
    {
    elemlist *p = start;
    start = new elemlist;
    start -> key = n;
    start -> next = p;
    }

    //Dobavqne na element v spisuka otkraq
    void add_e(int n)
    {
    elemlist *p = start, *q;
    q = new elemlist;
    q -> key = n;
    q -> next = NULL;
    if(start == NULL) start = q;
    else
    {
    while(p -> next) p = p -> next;
    p -> next = q;
    }
    }

    //Za slagane na tabulatori pri izvejdane na durvoto
    void printnode(int n, int h)
    {
    for(int i = 0; i < h; i++) cout<<"\t";
    cout<<n<<endl;
    }

    //Za izvejdane na durvoto
    void show(elemtree *t, int h)
    {
    if(t)
    {
    //cout<<t -> key;
    show(t -> right,h+1);
    printnode(t -> key,h);
    show(t -> left,h+1);
    }
    }

    //Za dobavqne na element v durvoto
    void add(int n, elemtree *&t)
    {
    if(t == NULL)
    {
    t = new elemtree;
    t -> key = n;
    t -> bal = 0;
    t -> left = t -> right = NULL;
    }
    else
    {
    if(t -> key > n)
    {
    if(t -> bal != -1) t -> bal--;
    add(n,t -> left);
    }
    else
    {
    if(t -> key < n)
    {
    if(t -> bal != 1) t -> bal++;
    add(n,t -> right);
    }
    }
    }
    }

  4. #4
    a.k.a. alexandar888
    Join Date: Dec:2008
    Location:
    Posts: 1,071
    , .

  5. #5
    Registered User
    Join Date: Apr:2007
    Location:
    Posts: 184
    pepi9846, .

    . . , . , , - , .

    , , . , , - . . , - .

    AVL Trees: Tutorial and C++ Implementation - AVL Brad Appleton. , .
    Last edited by BBelchev; 4th May 2018 at 03:32.

  6. #6
    Registered User
    Join Date: Mar:2018
    Location: pleven
    Posts: 6
    . .

  7. #7
    Mire-x
    Join Date: Apr:2005
    Location: Sofia
    Posts: 763
    .
    (10b) || !(10b)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |