Я сделала ввод массива с клавиатуры, но ты можешь сделать его рандомными числами
const N=5;
var A: array [1..N] of real;
i: integer;
begin
writeln('Введите массив');
for i:=1 to N do
readln(A[i]);
writeln('Положительные элементы:');
for i:=1 to N do
if A[i]>0 then
writeln('A[', i, ']=', A[i]);
end.
#include "stdafx.h"
#include <iostream>
#include <stdio.h>
using namespace std;
int main ()
{
short int x1,y1,x2,y2;
cout << "Input x1: ";
cin>> x1;
cout<<endl<<"Input y1: ";
cin>> y1;
cout << "Input x2: ";
cin>> x2;
cout<<endl<<"Input y2: ";
cin>> y2;
if ((abs(x2-x1)!=1) || (abs(y2-y1) !=2))
{cout<<"NOT";} else
{cout<<"OK"<<endl;}
system("PAUSE");
return 0;
var
i, si, N, ss: Integer;
s: string;
begin
Write ('Введите N: ');
ReadLn (N);
s := IntToStr (N);
ss := 0;
for i := 1 to Length (s) do begin
si := StrToInt (s [i]);
if si mod 4 <> 0 then
ss := ss + si;
end;
Writeln ('Сумма цифр = ' + IntToStr (ss));
end.
// второй вариант решения
var
si, N, ss: Integer;
begin
Write ('Введите N: ');
ReadLn (N);
ss := 0;
while N > 0 do begin
si := N mod 10;
N := N div 10;
if si mod 4 <> 0 then
ss := ss + si;
end;
Writeln ('Сумма цифр = ' + IntToStr (ss));
end.