Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. int main()
  2. {
  3.   ifstream in("in.txt");
  4.   ofstream out("out.txt");
  5.  
  6.   int i;
  7.   in >> i;
  8.  
  9.   vector<vector<double>> matrix(i, vector<double>(i, 0));
  10.   int a, b;
  11.   double w;
  12.  
  13.   while (in >> a >> b >> w)
  14.     {
  15.       matrix[a-1][b-1] = w;
  16.     }
  17.  
  18.   out << fixed << setprecision(1);
  19.   for (int x = 0; x < matrix.size(); x++)
  20.     {
  21.       for (int y = 0; y < matrix.size(); y++)
  22.     out << matrix[x][y] << '\t';
  23.       out << endl;
  24.     }
  25.  
  26.   marks.assign(i, false);
  27.   dfs(0, matrix);
  28.  
  29.   for (int z = 0; z < marks.size(); z++)
  30.     out << marks[z] << '\t';
  31.   out << endl;
  32.  
  33.   // Нерабочий код
  34.   /*
  35.   marks.assign(i, false);
  36.   bfs(0, matrix);
  37.  
  38.   for (int z = 0; z < marks.size(); z++)
  39.     out << marks[z] << '\t';
  40.   out << endl;
  41.   */  
  42.   return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement