#include <stdio.h>#include <stdlib.h> #define MAX 16 void main(void){ int i, A[MAX], TRI[MAX], ODD[MAX], null = 0, minus = 0, tre = 0, k; for (i = 0; i < MAX; i++) { if (i % 2 == 0) { k = 1; A[i] = k * i; } else { k = -1; A[i] = k * i; } } for (i = 0; i < MAX; i++) { if (A[i] == 0) null++; if (A[i] % 2 == 0) { ODD[i] = A[i]; printf("Even: %i\n", i); } if (A[i] < 0) minus++; if (A[i] % 3 == 0) { tre++; TRI[i] = A[i]; printf("Del on tri = 0: %i\n", i); } }}
Const n=15; Var a:array[1..n] of integer; i,indx,k,tr,indxx:integer; Begin Randomize; For i:=1 to n do begin A[i]:=Random(40)-20; Write(a[i],' '); end; Writeln; write('0 имеет номер: '); For i:=1 to n do Begin If A[i]=0 thenwrite(i); end; Writeln; indx:=0; For i:=1 to n do Begin If a[i] mod 2=0 then begin indx += 1; a[indx]:=a[i]; end; end; Write('Индекс четных элементов: '); For i:=1 to indx do write(a[i],' '); For i:=1 to n do Begin If A[i]<0 then Begin inc(k); end; end; Writeln; Writeln('Кoличество отрицательных элементов: ',k); For i:=1 to n do Begin If A[i] mod 3=0 then tr:=a[i]; end; Writeln('Кратное трем ',tr); indxx:=0; writeln('Индексы кратны 3: '); For i:=1 to n do Begin If a[i] mod 3=0 then begin indxx += 1; a[indxx]:=a[i]; write(' ',a[i]); end; end; end.
#include <stdio.h>#include <stdlib.h>
#define MAX 16
void main(void){ int i, A[MAX], TRI[MAX], ODD[MAX], null = 0, minus = 0, tre = 0, k;
for (i = 0; i < MAX; i++) { if (i % 2 == 0) { k = 1; A[i] = k * i; } else { k = -1; A[i] = k * i; } }
for (i = 0; i < MAX; i++) { if (A[i] == 0) null++;
if (A[i] % 2 == 0) { ODD[i] = A[i]; printf("Even: %i\n", i); }
if (A[i] < 0) minus++;
if (A[i] % 3 == 0) { tre++; TRI[i] = A[i]; printf("Del on tri = 0: %i\n", i); } }}
Var a:array[1..n] of integer;
i,indx,k,tr,indxx:integer;
Begin
Randomize;
For i:=1 to n do begin
A[i]:=Random(40)-20;
Write(a[i],' ');
end;
Writeln;
write('0 имеет номер: ');
For i:=1 to n do
Begin
If A[i]=0 thenwrite(i);
end;
Writeln;
indx:=0;
For i:=1 to n do
Begin
If a[i] mod 2=0 then
begin
indx += 1;
a[indx]:=a[i];
end;
end;
Write('Индекс четных элементов: ');
For i:=1 to indx do
write(a[i],' ');
For i:=1 to n do
Begin
If A[i]<0 then
Begin
inc(k);
end;
end;
Writeln;
Writeln('Кoличество отрицательных элементов: ',k);
For i:=1 to n do
Begin
If A[i] mod 3=0 then
tr:=a[i];
end;
Writeln('Кратное трем ',tr);
indxx:=0;
writeln('Индексы кратны 3: ');
For i:=1 to n do
Begin
If a[i] mod 3=0 then
begin
indxx += 1;
a[indxx]:=a[i];
write(' ',a[i]);
end;
end;
end.