Advertisement
Kentoo

A#1

Jan 22nd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <cmath>
  5. #include <clocale>
  6.  
  7. using namespace std;
  8.  
  9. void main()
  10. {
  11.     setlocale(LC_ALL, "Russian");
  12.     const int N = 3, M = 7;
  13.     int a[N][M];
  14.     for (int i = 0; i < N; i++) {
  15.         for (int j = 0; j < M; j++) {
  16.             a[i][j] = rand() % 10;
  17.             cout << setw(4) << a[i][j] << " ";
  18.         }
  19.         cout << endl;
  20.     }
  21.     cout << endl;
  22.     int k = 0;
  23.     double p;
  24.     for (int i = 0; i < M; i++) {
  25.         if (a[0][i] == a[1][i] && a[0][i] != a[2][i] || a[0][i] == a[2][i] && a[0][i] != a[1][i] || a[1][i] == a[2][i] && a[1][i] != a[0][i]) {
  26.             k++;
  27.             p = (a[0][i] + a[1][i] + a[2][i]) / 2.0;
  28.             cout << "Найден равнобедренный треугольник в " << i + 1 << "столбце с площадью " << sqrt(p * (p - a[0][i]) * (p - a[1][i]) * (p - a[2][i])) << endl;
  29.         }
  30.     }
  31.     cout << "Всего найдено " << k << " равнобедренных треугольников" << endl;
  32.     system("pause");
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement