Advertisement
avukas

2011 popravni je_li_matrica

Mar 4th, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include<vector>
  3. #include<stdexcept>
  4.  
  5. void funkcija(std::vector<std::vector<int>> v)
  6. {
  7.     for (int i(0); i<v.size(); i++)
  8.     {
  9.       if (v[0].size() != v[i].size())
  10.         throw std::domain_error("Nije matrica.");
  11.     }
  12.  
  13. }
  14. int main()
  15. {
  16.     std::vector<std::vector<int>> v{{1, 2,3,6}, {4,5,6}, {7,8,9} };
  17.     try
  18.     {
  19.         funkcija(v);
  20.     }
  21.     catch(std::domain_error poruka)
  22.     {
  23.         std::cout<<poruka.what()<<std::endl;
  24.     }
  25.     return 0;
  26.  
  27.  
  28.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement