Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdexcept>
- #include <vector>
- using namespace std;
- bool GornjaTrougaona (vector<vector<double>> mat)
- {
- for (int i=0; i<mat.size(); i++) {
- if (mat[i].size()!=mat[0].size())
- throw domain_error ("Parametar nema formu matrice.");
- }
- for (int i=0; i<mat.size(); i++) {
- for (int j=0; j<mat[i].size(); j++)
- {
- if (i>j && mat[i][j]==0) return true;
- }}
- return false;
- }
- int main () {
- cout<<"Unesite dimenzije matrice :";
- int br_red, br_kol;
- cin>>br_red>>br_kol;
- try {
- vector<vector<double>> mat(br_red,vector<double>(br_kol));
- cout<<"Unesite elemente matrice: "<<endl;
- for (int i=0; i<br_red; i++)
- for (int j=0; j<br_kol; j++)
- cin>>mat[i][j];
- if (GornjaTrougaona(mat)) cout<<"Matrica je gornja trougaona.";
- else cout<<"Matrica nije gornja trougaona.";
- }
- catch(const char poruka[]) {
- cout<<poruka;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement