Results 1 to 4 of 4
Thread: BFS Dev C++
Hybrid View
-
7th February 2010 22:08 #1
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
-
7th February 2010 22:48 #2Registered User
Join Date: Dec:2007
Location: Sofia
Posts: 366
, .
( -), CODE .
-
8th February 2010 20:02 #3
, ,
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
-
8th February 2010 21:43 #4Registered User
Join Date: Dec:2007
Location: Sofia
Posts: 366
- , - .
- , ( , http://en.wikipedia.org/wiki/Breadth-first_search), / .




Reply With Quote
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in