avukas

gornja trougaona matrica

Apr 18th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <iostream>
  2. #include<vector>
  3.  
  4. typedef std::vector<std::vector<int>> Matrica;
  5.  
  6. bool funkcija(Matrica m)
  7. {
  8.     bool trougaona=false;
  9.     for (int i(0); i<m.size(); i++)
  10.     {
  11.         for (int j(0); j<m[0].size(); j++)
  12.         {
  13.           if(i>0 && j<i)
  14.             {
  15.                 if(m[i][j] == 0)
  16.                 trougaona = true;
  17.           }
  18.         }
  19.     }
  20.     return trougaona;
  21. }
  22. int main()
  23. {
  24.     int m, n;
  25.     std::cout<<"Unesi dimenziju matrice:\n";
  26.     std::cin>>m>>n;
  27.     Matrica mat(m, std::vector<int>(n));
  28.     std::cout<<"Unesi clanove matrice:\n";
  29.     for (int i(0); i<m; i++)
  30.     {
  31.         for(int j(0); j<n; j++)
  32.         {
  33.             std::cin>>mat[i][j];
  34.         }
  35.     }
  36.     bool rez = funkcija(mat);
  37.     std::cout<<"\n rezultat: "<< rez;
  38.  
  39.  
  40.  
  41.  
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment