#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
srand((int)time(0));
int M, N;
cout << "M="; cin >> M;
do
{
cout << "N="; cin >> N;
if (N%2!=0) cout << "N - even. Repeat please...\n";
}
while (N%2!=0);
double **a = new double*[M];
for (int i = 0; i < M; i++)
a[i]=new double[N];
for (int i = 0; i < M; i++)
{
for (int j = 0; j < N; j++)
{
a[i][j]=rand()%9 + 1;
cout << a[i][j] << " ";
}
cout << "\n";
}
cout << "\n";
for (int i = 0; i < M; i++)
for (int j = 0; j < N/2; j++)
swap (a[i][j],a[i][j+N/2]);
for (int i = 0; i < M; i++)
{
for (int j = 0; j < N; j++)
cout << a[i][j] << " ";
cout <<"\n";
}
for (int i = 0; i < M; i++)
delete[]a[i];
delete[]a;
system("pause");
return 0;
}
Объяснение:
1)
var a,b:longint;
begin
readln(a,b);
writeln(a+b);
end.
2)
var x:longint;
begin
readln(x);
if(x>0) then writeln(x-6) else if(x=0) then writeln(32*x-7) else if(x<0) then writeln(5*x-2);
end.
3) В третьей условие не совсем понял, если что, дополни, отредактирую код. Какие значения принимают элементы (по какому принципу заполняется массив)? Написал для массива с элементами от 1 до 50.
var a:array[1..50] of integer;
var i:integer;
begin
for i:=1 to 50 do a[i]:=i;
for i:=1 to 50 do writeln(a[i]);
end.