Click here to Skip to main content
15,886,806 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionWrong Output, Cant catch the mistake (DFS) Pin
zeego4-Oct-09 20:51
zeego4-Oct-09 20:51 
AnswerRe: Wrong Output, Cant catch the mistake (DFS) Pin
DeepakMega4-Oct-09 21:26
DeepakMega4-Oct-09 21:26 
GeneralRe: Wrong Output, Cant catch the mistake (DFS) Pin
zeego4-Oct-09 22:30
zeego4-Oct-09 22:30 
AnswerRe: Wrong Output, Cant catch the mistake (DFS) Pin
Saurabh.Garg4-Oct-09 22:53
Saurabh.Garg4-Oct-09 22:53 
GeneralRe: Wrong Output, Cant catch the mistake (DFS) Pin
zeego4-Oct-09 23:07
zeego4-Oct-09 23:07 
AnswerRe: Wrong Output, Cant catch the mistake (DFS) Pin
DeepakMega4-Oct-09 23:32
DeepakMega4-Oct-09 23:32 
GeneralRe: Wrong Output, Cant catch the mistake (DFS) Pin
zeego4-Oct-09 23:45
zeego4-Oct-09 23:45 
GeneralRe: Wrong Output, Cant catch the mistake (DFS) Pin
zeego12-Oct-09 20:52
zeego12-Oct-09 20:52 
Cant get it to work. The output is a blank screen Frown | :(

#include <stdio.h>
#include <conio.h>
#define MAX 6			// Node/Vertex count
int adj[MAX][MAX]={      // Adjacency Matrix 2x2
			    {0,1,1,1,0,0},
			    {1,0,0,0,1,1},
			    {1,0,0,0,0,0},
			    {1,0,0,0,0,0},
			    {0,1,0,0,0,0},
			    {0,1,1,0,0,0}
			};

int visited[MAX];	// Visited array
void bfs(int goal);	// bfs function


int main ()
	{
		int s=3;	//set Source node
		clrscr();
		printf("The nodes order is ");
		bfs(s);
		return 0;


	}

void bfs(int source)
	{
	   int queue[MAX];
	   int i,front,rear,root;
	   front=rear=0;

	   for (i=1;i<MAX;i++)
	   {
		   visited[i]=0;
	   }



	   queue[++rear]=source;
	   visited[source]=1;

	   printf("%d :",source);

		while(rear!=front)
			{
				root=queue[++front];
				for(i=0;i<MAX;i++)

					if (adj[root][i] && !visited[i])
					{
						queue[rear++]=i;
						visited[i]=1;
						printf("%d",i);
					}


				front++;
			}


	   }

GeneralRe: Wrong Output, Cant catch the mistake (DFS) Pin
DeepakMega12-Oct-09 22:17
DeepakMega12-Oct-09 22:17 
GeneralRe: Wrong Output, Cant catch the mistake (DFS) Pin
zeego12-Oct-09 23:14
zeego12-Oct-09 23:14 
GeneralRe: Wrong Output, Cant catch the mistake (DFS) Pin
DeepakMega12-Oct-09 22:48
DeepakMega12-Oct-09 22:48 
GeneralRe: Wrong Output, Cant catch the mistake (DFS) Pin
zeego12-Oct-09 23:11
zeego12-Oct-09 23:11 
GeneralRe: Wrong Output, Cant catch the mistake (DFS) Pin
DeepakMega12-Oct-09 23:45
DeepakMega12-Oct-09 23:45 
GeneralRe: Wrong Output, Cant catch the mistake (DFS) Pin
zeego13-Oct-09 21:39
zeego13-Oct-09 21:39 
GeneralRe: Wrong Output, Cant catch the mistake (DFS) Pin
zeego12-Oct-09 23:38
zeego12-Oct-09 23:38 
QuestionVARIANT to CString Pin
Davitor4-Oct-09 20:28
Davitor4-Oct-09 20:28 
AnswerRe: VARIANT to CString Pin
Code-o-mat4-Oct-09 20:37
Code-o-mat4-Oct-09 20:37 
GeneralRe: VARIANT to CString Pin
Davitor4-Oct-09 20:41
Davitor4-Oct-09 20:41 
GeneralRe: VARIANT to CString Pin
Code-o-mat4-Oct-09 21:00
Code-o-mat4-Oct-09 21:00 
GeneralRe: VARIANT to CString Pin
Stuart Dootson4-Oct-09 22:13
professionalStuart Dootson4-Oct-09 22:13 
QuestionHow to pass the command to createprocess() Pin
WindowsVsLinux4-Oct-09 20:16
WindowsVsLinux4-Oct-09 20:16 
AnswerRe: How to pass the command to createprocess() Pin
Madhu Nair4-Oct-09 20:56
Madhu Nair4-Oct-09 20:56 
GeneralRe: How to pass the command to createprocess() Pin
WindowsVsLinux4-Oct-09 22:16
WindowsVsLinux4-Oct-09 22:16 
AnswerRe: How to pass the command to createprocess() Pin
Michael Schubert4-Oct-09 21:10
Michael Schubert4-Oct-09 21:10 
GeneralRe: How to pass the command to createprocess() Pin
WindowsVsLinux4-Oct-09 22:20
WindowsVsLinux4-Oct-09 22:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.