Const K = 3; N = 4; Var A:array[1..K,1..N] of integer; Max,Min,i,j:integer; Begin For i:= 1 to K do Begin For j:= 1 to N do Begin A[i,j]:=random(21)-10; Write(A[i,j]:3,' ') End; WriteLn End; Max:=A[K,N]; Min:=A[K,N]; For i:= 1 to K do For j:= 1 to N do Begin if Max<A[i,j] then Max:=A[i,j]; if Min>A[i,j] then Min:=A[i,j] End; WriteLn('Min = ',Min); WriteLn('Max = ',Max); End.
using namespace std;
string evenOrOdd(int n)
{
if (n % 2 == 0) {
return "чётное";
}
else {
return "нечётное";
}
}
string digitCount(int n)
{
if ( (int) n / 1000 > 0 ) {
if (n > 9999){
return "n-значное";
}
else {
return "четырёхзначное";
}
}
else if ( (int) n % 1000 / 100 > 0 ) {
return "трёхзначное";
}
else if ( (int) n % 100 / 10 > 0 ) {
return "двузначное";
}
else {
return "однозначное";
}
}
int main()
{
int n;
cout << "n = ";
cin >> n;
cout << evenOrOdd(n) << ' '
<< digitCount(n) << ' '
<< "число" << endl;
return 0;
}
K = 3;
N = 4;
Var
A:array[1..K,1..N] of integer;
Max,Min,i,j:integer;
Begin
For i:= 1 to K do
Begin
For j:= 1 to N do
Begin
A[i,j]:=random(21)-10;
Write(A[i,j]:3,' ')
End;
WriteLn
End;
Max:=A[K,N];
Min:=A[K,N];
For i:= 1 to K do
For j:= 1 to N do
Begin
if Max<A[i,j] then Max:=A[i,j];
if Min>A[i,j] then Min:=A[i,j]
End;
WriteLn('Min = ',Min);
WriteLn('Max = ',Max);
End.
Пример:
-3 -2 5 -8
2 -3 7 5
-10 -2 7 4
Min = -10
Max = 7