Var
a:array [1..100] of integer;
i:integer;
begin
randomize;
write('массив:');
writeln;
begin
for i:=1 to 100 do
a[i]:=random (40)-20;
end;
for i:=1 to 100 do
writeln(a[i]);
end.
Const
m=5;
n=3;
var
i,j,k:integer;
a:array[1..m,1..n] of integer;
begin
Randomize;
Writeln('Исходный массив');
k:=0;
for i:=1 to m do begin
for j:=1 to n do begin
a[i,j]:=Random(999)+1;
Write(a[i,j]:4);
if (a[i,j] mod 8=0) and (a[i,j] mod 10=4) then Inc(k);
end;
Writeln
end;
if k>0 then begin
Writeln('Искомые элементы');
for i:=1 to m do
for j:=1 to n do
if (a[i,j] mod 8=0) and (a[i,j] mod 4=10) then Write(a[i,j],' ')
end
else
Writeln('Нет элементов, кратных 8 и оканчивающихся на 4')
end.
Пример работы программы
Исходный массив
424 672 826
546 587 413
507 211 884
252 781 518
750 656 359
Искомые элементы
424
Const n=3;
type lec=record
name:string;
cost:integer;
end;
var a:array [1..n] of lec;
max1:integer;
m,k,p,i:byte;
begin
for i:=1 to n do
with a[i] do begin
writeln ('Введи наименование товара');
readln (name);
writeln ('введи стоимость товара');
readln (cost);
end;
max1:=-1;
for i:=1 to n do
if a[i].cost>max1 then begin max1:=a[i].cost;
p:=i;
end;
while k<>1 do begin
for i:=1 to n do
if (i<>p) and (a[i].cost=max1) then begin m:=i;
k:=1;
end;
max1:=max1-1;
end;
writeln (a[p].name,' ',a[p].cost);
write (a[m].name,' ',a[m].cost);
readln;
end.
Var
a:integer;
begin
Read(a);
if (a < 18) then Writeln('Вы не совершеннолетний')
else Writeln('Вы совершеннолетний')
end.
Public static void SomeAction()
{
int number = 0;
int sum = 0;
<span>int num = int.Parse(Console.ReadLine());</span>
while (num != 0)
{
if (num % 5 == 0 && num % 7 != 0)
{
sum += num;
number++;
}
num = int.Parse(Console.ReadLine());
}
Console.WriteLine("Количество требуемых чисел: " + number);
Console.WriteLine("Их сумма: " + sum);
}