#include #include using namespace std; int * visit; int ** graph; int n; void read(char * name){ ifstream fin; fin.open(name, ios_base::in); fin >> n; int i, j; graph = new int*[n]; visit = new int[n]; for(i = 0; i < n; i++) graph[i] = new int[n]; for(i = 0; i < n; i++) for( j = 0; j < n; j++) fin >> graph[i][j]; fin.close(); } void DFS(int a) { int i; cout << a+1 << " "; visit[a] = 1; for(i = 0; i <= n; i++) if(!visit[i] && graph[a][i]) DFS[i]; } int main(){ int s; int i, j; read("gr.txt"); cout<<"Matriza smeznosti: "<> s; cout << "Obhod: "; DFS(s); cout << endl << "Vershini, k kotoruim est pyt: " ; for (int i = 0; i < n; i++) if(visit[i] == 1) cout << i+1 << " "; delete [] visit; return 0; }