Results 1 to 4 of 4

Thread: BFS Dev C++

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Mes Que Un Club F3N0M3NA's Avatar
    Join Date: Nov:2008
    Location: Sofia
    Posts: 175

    BFS Dev C++

    , . , :

    #include <iostream>
    #include <queue>
    using namespace std;
    bool Graph [6][6]={
    {0,0,1,1,1,0},
    {0,0,0,0,0,1},
    {1,0,0,0,0,1},
    {1,0,0,0,0,0},
    {1,0,0,0,0,0},
    {0,1,1,0,0,0}
    };
    queue <int> Verts;
    bool Used[6];
    int cur,vert;
    void bfs(int n) {
    Verts.push(n);
    Used[n]=true;
    while(!Verts.empty()) {
    cur=Verts.front ();
    cout <<cur<<" ";
    Verts.pop();
    for (int i=0;i<vert;i++) {
    if ((Graph[cur][i]==true)&&(Used[i]==false)) {
    Verts.push(i);
    Used[i]=true;
    }
    }
    }
    }
    int main () {
    int n;
    cout <<"Vuvedete ot koi vruh se zapo4va obhojdaneto: ";
    cin >>n;
    bfs(n-1);
    system ("pause");
    return 0;
    }
    Q9550@4.3GHz | 3D Mark 06 GTX 280 | 3D Mark 06 4870x2 | 3D Mark 06 5850
    Asrock P67 Pro3|Intel Core i7 2600k|A-Data 2X2GB DDR3 @ 1866MHz 8-8-8-24|Sapphire 6850|WD Caviar Black 750GB Sata III 64MB|Coolermaster RealPower M700|Coolermaster HAF 922|Samsung SM P2350|A4Tech X755FS|Logitech Wave Keyboard

  2. #2
    Registered User
    Join Date: Dec:2007
    Location: Sofia
    Posts: 366
    , .
    ( -), CODE .

  3. #3
    Mes Que Un Club F3N0M3NA's Avatar
    Join Date: Nov:2008
    Location: Sofia
    Posts: 175
    , ,
    Q9550@4.3GHz | 3D Mark 06 GTX 280 | 3D Mark 06 4870x2 | 3D Mark 06 5850
    Asrock P67 Pro3|Intel Core i7 2600k|A-Data 2X2GB DDR3 @ 1866MHz 8-8-8-24|Sapphire 6850|WD Caviar Black 750GB Sata III 64MB|Coolermaster RealPower M700|Coolermaster HAF 922|Samsung SM P2350|A4Tech X755FS|Logitech Wave Keyboard

  4. #4
    Registered User
    Join Date: Dec:2007
    Location: Sofia
    Posts: 366

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 |