My C++ Coding for Moore Assignment

#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int

main()
{

int A,B,i,c,d;
vector<int> adjlist[10];
int dist[10];
queue<pair<int,int> > Q;
pair<int,int> P;

cout «"How many number of vertices? ";
cin » A;
cout «"How many number of edges? ";
cin » B;

for (i=0; i<A; i++)
dist[i]=-1;

for (i=0; i<B; i++)
{
cout «"Enter two vertices: ";
cin » c » d;
}

cout «"What is the starting vertex? ";
cin » c;

Q.push(make_pair(c,0));

while (!Q.empty())
{
P=Q.front();

Q.pop();

if (dist[P.first]!=-1)
continue;
}

for (i=0; i<A; i++)
{
cout «"The distance from vertex " « c « " to vertex " « i « ": ";

if (dist[i]==-1)
cout «"Error" « endl;
else
cout « dist[i] « endl;
}

return 0;
}

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License