В C++ #include <iostream> #include <iomanip> #include <ctime> int main() { using namespace std;
const int N = 5; const int M = 5;
//Создаём массив и как-нибудь заполняем int A[N][M]; srand(time(0)); for (int i = 0; i < N; ++i) for (int j = 0; j < M; ++j) A[i][j] = rand() % (N * M) + 1;
//Выводим его на экран for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) cout << setw(4) << A[i][j]; cout << endl; }
//Меняем местами 2ю и 3ю строки int temp = 0; for (int j = 0; j < M; ++j) { temp = A[1][j]; A[1][j] = A[2][j]; A[2][j] = temp; }
//Выводим полученный массив на экран cout << "\n\n"; for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) cout << setw(4) << A[i][j]; cout << endl; }
// PascalABC.NET 3.0, сборка 1144 от 16.01.2016 type Point=record x,y:real end;
function GetPoint(c:char):Point; begin Writeln('Введите координаты точки ',c,':'); Read(Result.x,Result.y) end;
function Line(A,B:Point):real; begin Result:=sqrt(sqr(B.x-A.x)+sqr(B.y-A.y)) end;
function SqTriangle(pA,pB,pC:Point):real; begin var a:=Line(pB,pC); var b:=Line(pA,pC); var c:=Line(pA,pB); if (a+b>c) and (a+c>b) and (b+c>a) then begin var p:=(a+b+c)/2; Result:=sqrt(p*(p-a)*(p-b)*(p-c)) end else Result:=0 end;
begin var A:=GetPoint('A'); var B:=GetPoint('B'); var C:=GetPoint('C'); Writeln('Площадь треугольника равна ',SqTriangle(A,B,C)) end.
Тестовое решение: Введите координаты точки A: -5 3.18 Введите координаты точки B: 1.45 6.2 Введите координаты точки C: 6 -5.93 Площадь треугольника равна 45.98975
#include <iostream>
#include <iomanip>
#include <ctime>
int main()
{
using namespace std;
const int N = 5;
const int M = 5;
//Создаём массив и как-нибудь заполняем
int A[N][M];
srand(time(0));
for (int i = 0; i < N; ++i)
for (int j = 0; j < M; ++j)
A[i][j] = rand() % (N * M) + 1;
//Выводим его на экран
for (int i = 0; i < N; ++i)
{
for (int j = 0; j < M; ++j)
cout << setw(4) << A[i][j];
cout << endl;
}
//Меняем местами 2ю и 3ю строки
int temp = 0;
for (int j = 0; j < M; ++j)
{
temp = A[1][j];
A[1][j] = A[2][j];
A[2][j] = temp;
}
//Выводим полученный массив на экран
cout << "\n\n";
for (int i = 0; i < N; ++i)
{
for (int j = 0; j < M; ++j)
cout << setw(4) << A[i][j];
cout << endl;
}
return 0;
}