Aleksandr_Grigoryev

треугольная

Feb 28th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. int main()
  6. {
  7.     int a[4][4] =
  8.     {
  9.         { 1,0,0,0 },
  10.         { 1,0,0,0 },
  11.         { 2,3,0,0 },
  12.         { 3,0,1,0 },
  13.     };
  14.     int n = 4;
  15.     bool b = true;
  16.     bool q = false;
  17.     for (int i = 0; i < n && b; i++)
  18.     {
  19.         for (int j = i + 1; j < n && b; j++)
  20.         {
  21.  
  22.             if (a[i][j] != 0)
  23.                 b = false;
  24.         }
  25.     }
  26.     if (b) {
  27.         for (int i = 0; i < n; i++)
  28.         {
  29.             for (int j = 0; j <= i; j++)
  30.             {
  31.                 if (a[i][j] != 0)
  32.                 {
  33.                     q = true;
  34.                 }
  35.             }
  36.         }
  37.     }
  38.     if (b && q) cout << "treugolnaya";
  39.     else cout << "ne treugolnaya ";
  40.     system("pause");
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment