// PascalABC.NET 3.1, сборка 1213 от 04.04.2016 const n=15; var a:array[1..n] of integer; i,t:integer; begin Randomize; for i:=1 to n do begin a[i]:=Random(90)+10; Write(a[i],' ') end; Writeln; for i:=1 to n div 2 do begin t:=a[i]; a[i]:=a[n-i+1]; a[n-i+1]:=t end; for i:=1 to n do Write(a[i],' ') end.
//Описание добавить не вышло на сайт, посему - в файле
#include "stdafx.h" #include <conio.h>
void swap(short &a, short &b) { short c = a; a = b;
b = c; }
void sort(short &a, short &b, short &c) { short min = a, max = c; if (min > b) min = b; if (min > c) min = c; if (max < a) max = a; if (max < b) max = b; b = a + b + c - min - max; a = min; c = max; }
if ((a1 == a2) && (b1 == b2) && (c1 == c2)) printf("Boxes are equal"); else if ((a1 <= a2) && (b1 <= b2) && (c1 <= c2)) printf_s("The first box is smaller than the second one"); else if ((a2 <= a1) && (b2 <= b1) && (c2 <= c1)) printf_s("The first box is larger than the second one"); else printf_s("Boxes are incomparable");
// PascalABC.NET 3.1, сборка 1213 от 04.04.2016
begin
var a:=ArrRandom(ReadInteger('n='),10,99); a.Println;
a:=a.Reverse.ToArray; a.Println
end.
Тестовое решение:
n= 15
33 91 99 60 56 92 99 23 33 25 62 27 42 27 11
11 27 42 27 62 25 33 23 99 92 56 60 99 91 33
2. Школьный вариант
// PascalABC.NET 3.1, сборка 1213 от 04.04.2016
const
n=15;
var
a:array[1..n] of integer;
i,t:integer;
begin
Randomize;
for i:=1 to n do begin
a[i]:=Random(90)+10;
Write(a[i],' ')
end;
Writeln;
for i:=1 to n div 2 do begin
t:=a[i]; a[i]:=a[n-i+1]; a[n-i+1]:=t
end;
for i:=1 to n do Write(a[i],' ')
end.
#include "stdafx.h"
#include <conio.h>
void swap(short &a, short &b) {
short c = a;
a = b;
b = c;
}
void sort(short &a, short &b, short &c)
{
short min = a,
max = c;
if (min > b) min = b;
if (min > c) min = c;
if (max < a) max = a;
if (max < b) max = b;
b = a + b + c - min - max;
a = min;
c = max;
}
int main()
{
short a1, b1, c1, a2, b2, c2;
scanf_s("%hd %hd %hd", &a1, &b1, &c1);
scanf_s("%hd %hd %hd", &a2, &b2, &c2);
sort(a1, b1, c1);
sort(a2, b2, c2);
if ((a1 == a2) && (b1 == b2) && (c1 == c2))
printf("Boxes are equal");
else
if ((a1 <= a2) && (b1 <= b2) && (c1 <= c2))
printf_s("The first box is smaller than the second one");
else
if ((a2 <= a1) && (b2 <= b1) && (c2 <= c1))
printf_s("The first box is larger than the second one");
else
printf_s("Boxes are incomparable");
_getch();
return 0;
}