Задание 5. Значение переменной М вычисляется по следующему правилу: M = K*5, если К>10, M = K+10 во всех остальных случаях B) Какое значение переменной М получится при К=9
1)function first(k,l,m,n:integer):boolean; begin if (((k mod 2=0) and (l mod 2<>0)) or ((l mod 2=0) and (k mod 2<>0)))=(((m mod 2=0) and (n mod 2<>0)) or ((n mod 2=0) and (m mod 2<>0))) then first:=true else first:=false; end;
2)function second(k,l,m,n:integer):boolean; begin if (k=m) or (l=n) or (((k+1)=m) and ((l+1)=n)) or (((k+2)=m) and ((l+2)=n)) or (((k+3)=m) and ((l+3)=n)) or (((k+4)=m) and ((l+4)=n)) or (((k+5)=m) and ((l+5)=n)) or (((k+6)=m) and ((l+6)=n)) or (((k-1)=m) and ((l-1)=n)) or (((k-2)=m) and ((l-2)=n)) or (((k-3)=m) and ((l-3)=n)) or (((k-4)=m) and ((l-4)=n)) or (((k-5)=m) and ((l-5)=n)) or (((k-6)=m) and ((l-6)=n)) or (((m+1)=k) and ((n+1)=l)) or (((m+2)=k) and ((n+2)=l)) or (((m+3)=k) and ((n+3)=l)) or (((m+4)=k) and ((n+4)=l)) or (((m+5)=k) and ((n+5)=l)) or (((m+6)=k) and ((n+6)=l)) or (((m-1)=k) and ((n-1)=l)) or (((m-2)=k) and ((n-2)=l)) or (((m-3)=k) and ((n-3)=l)) or (((m-4)=k) and ((n-4)=l)) or (((m-5)=k) and ((n-5)=l)) or (((m-6)=k) and ((n-6)=l)) or (((k-1)=m) and ((l+1)=n)) or (((k-2)=m) and ((l+2)=n)) or (((k-3)=m) and ((l+3)=n)) or (((k-4)=m) and ((l+4)=n)) or (((k-5)=m) and ((l+5)=n)) or (((k-6)=m) and ((l+6)=n)) or (((k-1)=m) and ((l+1)=n)) or (((k-2)=m) and ((l+2)=n)) or (((k-3)=m) and ((l+3)=n)) or (((k-4)=m) and ((l+4)=n)) or (((k-5)=m) and ((l+5)=n)) or (((k-6)=m) and ((l+6)=n)) or (((m-1)=k) and ((n+1)=l)) or (((m-2)=k) and ((n+2)=l)) or (((m-3)=k) and ((n+3)=l)) or (((m-4)=k) and ((n+4)=l)) or (((m-5)=k) and ((n+5)=l)) or (((m-6)=k) and ((n+6)=l)) or (((m-1)=k) and ((n+1)=l)) or (((m-2)=k) and ((n+2)=l)) or (((m-3)=k) and ((n+3)=l)) or (((m-4)=k) and ((n+4)=l)) or (((m-5)=k) and ((n+5)=l)) or (((m-6)=k) and ((n+6)=l)) then second:=true else second:=false; end;
begin
if (((k mod 2=0) and (l mod 2<>0)) or ((l mod 2=0) and (k mod 2<>0)))=(((m mod 2=0) and (n mod 2<>0)) or ((n mod 2=0) and (m mod 2<>0))) then first:=true else first:=false;
end;
2)function second(k,l,m,n:integer):boolean;
begin
if (k=m) or (l=n) or (((k+1)=m) and ((l+1)=n)) or (((k+2)=m) and ((l+2)=n)) or (((k+3)=m) and ((l+3)=n)) or (((k+4)=m) and ((l+4)=n)) or (((k+5)=m) and ((l+5)=n)) or (((k+6)=m) and ((l+6)=n)) or (((k-1)=m) and ((l-1)=n)) or (((k-2)=m) and ((l-2)=n)) or (((k-3)=m) and ((l-3)=n)) or (((k-4)=m) and ((l-4)=n)) or (((k-5)=m) and ((l-5)=n)) or (((k-6)=m) and ((l-6)=n)) or (((m+1)=k) and ((n+1)=l)) or (((m+2)=k) and ((n+2)=l)) or (((m+3)=k) and ((n+3)=l)) or (((m+4)=k) and ((n+4)=l)) or (((m+5)=k) and ((n+5)=l)) or (((m+6)=k) and ((n+6)=l)) or (((m-1)=k) and ((n-1)=l)) or (((m-2)=k) and ((n-2)=l)) or (((m-3)=k) and ((n-3)=l)) or (((m-4)=k) and ((n-4)=l)) or (((m-5)=k) and ((n-5)=l)) or (((m-6)=k) and ((n-6)=l)) or (((k-1)=m) and ((l+1)=n)) or (((k-2)=m) and ((l+2)=n)) or (((k-3)=m) and ((l+3)=n)) or (((k-4)=m) and ((l+4)=n)) or (((k-5)=m) and ((l+5)=n)) or (((k-6)=m) and ((l+6)=n)) or (((k-1)=m) and ((l+1)=n)) or (((k-2)=m) and ((l+2)=n)) or (((k-3)=m) and ((l+3)=n)) or (((k-4)=m) and ((l+4)=n)) or (((k-5)=m) and ((l+5)=n)) or (((k-6)=m) and ((l+6)=n)) or (((m-1)=k) and ((n+1)=l)) or (((m-2)=k) and ((n+2)=l)) or (((m-3)=k) and ((n+3)=l)) or (((m-4)=k) and ((n+4)=l)) or (((m-5)=k) and ((n+5)=l)) or (((m-6)=k) and ((n+6)=l)) or (((m-1)=k) and ((n+1)=l)) or (((m-2)=k) and ((n+2)=l)) or (((m-3)=k) and ((n+3)=l)) or (((m-4)=k) and ((n+4)=l)) or (((m-5)=k) and ((n+5)=l)) or (((m-6)=k) and ((n+6)=l)) then second:=true else second:=false;
end;
#include <iostream>
#include <ctime>
using namespace std;
int main() {
const int n = 4;
float arr[n][10];
cout << "Исходный массив: " << endl;
srand(time(NULL));
for (int i = 0; i < n; i++){
for (int j = 0; j < 10; j++){
float minValue = -10.f;
float maxValue = 10.f;
arr[i][j] = (float)rand()/(float) RAND_MAX * (maxValue - minValue) + minValue;
cout << arr[i][j] << " ";
}
cout << endl;
}
int maxIndex = 0;
for (int i = 0; i < n; i++)
for (int j = 0; j < 10; j++)
if (arr[i][j] >= arr[maxIndex/10][maxIndex%10])
maxIndex = i * 10 + j;
cout << "Max: " << "arr["<<maxIndex/10<<"]["<<maxIndex%10<<"] = "
<< arr[maxIndex/10][maxIndex%10] << endl;
int row = maxIndex/10;
if (row < n - 1){
cout << "Меняем " << row + 1 << " и " << n << " строки местами: " << endl;
for (int j = 0; j < 10; j++){
float temp = arr[n-1][j];
arr[n-1][j] = arr[row][j];
arr[row][j] = temp;
}
for (int i = 0; i < n; i++){
for (int j = 0; j < 10; j++)
cout << arr[i][j] << " ";
cout << endl;
}
} else {
cout << "Максимальный элемент находится на последней строке." << endl;
}
return 0;
}