What would be the output of the following C++ program if the given input is [code] 0 0 0 1 1 0 0 0 0 1 0 0 0 1 0 1 0 1 0 0 1 1 0 0 0 #include

What would be the output of the following C++ program if the given input is
Code:
0 0 0 1 1
0 0 0 0 1
0 0 0 1 0
1 0 1 0 0
1 1 0 0 0
#include <bits/stdc++.h>
using namespace std;
bool visited[5];
int G[5][5];
void fun(int i)
{
	cout<<i<<" ";
	visited[i]=true;
	for(int j=0;j<5;j++)
		if(!visited[j]&#038;&#038;G[i][j]==1)
			fun(j);
}
int main()
{   
	for(int i=0;i<5;i++)
		for(int j=0;j<5;j++)
			cin>>G[i][j];
	for(int i=0;i<5;i++)
		visited[i]=0;
	fun(0);
		return 0;
}
A. 0 2 3 1 4
B. 0 3 2 4 1
C. 0 2 3 4 1
D. 0 3 2 1 4
 

Tìm kiếm

Back
Top