Var a1,a2,a3,a4,a5,a6,a7,a8,k:integer; begin k:=0; read (a1,a2,a3,a4,a5,a6,a7,a8); if (a1>0) and (a2>0) and (a3>0) and (a4>0) and (a5>0) and (a6>0) and (a7>0) and (a8>0) then begin if (a1 mod 3 = 0) and (a1 mod 10 = 4) then k:=k+1; if (a2 mod 3 = 0) and (a2 mod 10 = 4) then k:=k+1; if (a3 mod 3 = 0) and (a3 mod 10 = 4) then k:=k+1; if (a4 mod 3 = 0) and (a4 mod 10 = 4) then k:=k+1; if (a5 mod 3 = 0) and (a5 mod 10 = 4) then k:=k+1; if (a6 mod 3 = 0) and (a6 mod 10 = 4) then k:=k+1; if (a7 mod 3 = 0) and (a7 mod 10 = 4) then k:=k+1; if (a8 mod 3 = 0) and (a8 mod 10 = 4) then k:=k+1; writeln (k); end else writeln ('Неверный ввод'); end.
Код:
#include <iostream>
int* rearrange(int *A, int Asize) {
int * result = new int[Asize];
int p = 0;
for (int i = 0; i < Asize; i += 2) {
result[p] = A[i];
++p;
}
for (int i = 1; i < Asize; i += 2) {
result[p] = A[i];
++p;
}
return result;
}
void print_arr(const int *A, int Asise) {
for (int i = 0; i < Asise; ++i) {
std::cout << A[i] << " ";
}
}
int* change_it_k_times(int * const A, int Asize, int K) {
int * result = A;
for (auto i = 0; i < K; ++i) {
result = rearrange(result, Asize);
print_arr(result, Asize);
}
return result;
}
template <typename T>
void get_sequence(T* A, int N) {
for (auto i = 0; i < N; ++i) {
std::cin >> A[i];
}
}
int main () {
int N, K;
std::cin >> N;
auto A = new int[N];
get_sequence(A, N);
std::cin >> K;
auto R = change_it_k_times(A, N, K);
delete[] A;
delete[] R;
return 0;
}
begin
k:=0;
read (a1,a2,a3,a4,a5,a6,a7,a8);
if (a1>0) and (a2>0) and (a3>0) and (a4>0) and (a5>0) and (a6>0) and (a7>0) and (a8>0) then
begin
if (a1 mod 3 = 0) and (a1 mod 10 = 4) then k:=k+1;
if (a2 mod 3 = 0) and (a2 mod 10 = 4) then k:=k+1;
if (a3 mod 3 = 0) and (a3 mod 10 = 4) then k:=k+1;
if (a4 mod 3 = 0) and (a4 mod 10 = 4) then k:=k+1;
if (a5 mod 3 = 0) and (a5 mod 10 = 4) then k:=k+1;
if (a6 mod 3 = 0) and (a6 mod 10 = 4) then k:=k+1;
if (a7 mod 3 = 0) and (a7 mod 10 = 4) then k:=k+1;
if (a8 mod 3 = 0) and (a8 mod 10 = 4) then k:=k+1;
writeln (k);
end else
writeln ('Неверный ввод');
end.