Advertisement
AbraaoAllysson

leitura de vector de vector

May 31st, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1.  
  2. std::vector< std::vector<int> > readInput()
  3. {
  4. int route = 0,
  5. numberInput = 0;
  6.  
  7. std::cin >> route;
  8.  
  9. std::vector< std::vector<int> > mDistance;
  10.  
  11. for (int i = 0; i < route; i++)
  12. {
  13. std::vector<int> vTemp;
  14. for (int j = 0; j < route; j++)
  15. {
  16. std::cin >> numberInput;
  17. vTemp.push_back ( numberInput );
  18. }
  19. mDistance.push_back( vTemp );
  20. }
  21.  
  22. std::cout << "\n \t *************** \n" << std::endl;
  23. // Print out the elements
  24. for(unsigned int i = 0; i< mDistance.size(); i++)
  25. {
  26. for (unsigned int j = 0; j < mDistance[i].size(); j++)
  27. std::cout << "\t" << mDistance[i][j] << " ";
  28.  
  29. std::cout << std::endl;
  30. }
  31.  
  32. return mDistance;
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement