#include <iostream> #include <cstdlib> #include <ctime> int main() { using namespace std; cout << "Enter size of array: "; int N; cin >> N; int * ARR = new int[N]; srand(time(0)); int i; for (i = 0; i < N; ++i) ARR[i] = rand() % 100 + 1;
cout << "Here is an original array:\n"; for (i = 0; i < N; ++i) cout << ARR[i] << " "; cout << endl;
int temp = ARR[N - 1]; for (i = N - 1; i > 0; --i) ARR[i] = ARR[i - 1]; ARR[0] = temp;
cout << "\nHere is a new array:\n"; for (i = 0; i < N; ++i) cout << ARR[i] << " "; cout << endl;
#include <cstdlib>
#include <ctime>
int main()
{
using namespace std;
cout << "Enter size of array: ";
int N;
cin >> N;
int * ARR = new int[N];
srand(time(0));
int i;
for (i = 0; i < N; ++i)
ARR[i] = rand() % 100 + 1;
cout << "Here is an original array:\n";
for (i = 0; i < N; ++i)
cout << ARR[i] << " ";
cout << endl;
int temp = ARR[N - 1];
for (i = N - 1; i > 0; --i)
ARR[i] = ARR[i - 1];
ARR[0] = temp;
cout << "\nHere is a new array:\n";
for (i = 0; i < N; ++i)
cout << ARR[i] << " ";
cout << endl;
return 0;
}
1) program Array16;
var
i:integer; // счетчик в цикле
N:integer;
a: array [1..10] of integer;
begin
writeln('Введите N (N<10)');
readln(N); // ввод размера массива
for i:=1 to N do
begin
write('a[',i,']=');
readln(A[i]); // ручной ввод значений массива
end;
writeln('Результат');
for i:=1 to N do
begin
// вычисление и вывод элементов в указанном порядке
write(' ',a[(i div 2+1)*((i) mod 2)+ n*((i+1)mod 2)-((i div 2)-1)*((i+1) mod 2)]);
end;
end.
2) Var A:array[1..100] of integer;
i,n:byte;
Begin
write('Введите n<=100: ');readln(n);
For i:=1 to n do
Begin
A[i]:=random(31);
write(A[i]:3);
End;
writeln;
For i:=1 to n div 2 do
write(A[i]:3,A[n-i+1]:3);
if n mod 2 <>0 then write(A[n div 2+1]:3);
End.