#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;
var i,j,n:longint; f:boolean; begin writeln('Введите число'); readln(n); if n<2 then writeln('Простых делителей нет') else begin write('Число ',n,' ','= 1'); for i:=2 to n do if n mod i=0 then begin f:=true; j:=2; while f and(j<=round(sqrt(i/2)))do begin if i mod j=0 then f:=false else j:=j+1; end; if f then write('*',i); end; end; end.
#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;
}
var i,j,n:longint;
f:boolean;
begin
writeln('Введите число');
readln(n);
if n<2 then writeln('Простых делителей нет')
else
begin
write('Число ',n,' ','= 1');
for i:=2 to n do
if n mod i=0 then
begin
f:=true;
j:=2;
while f and(j<=round(sqrt(i/2)))do
begin
if i mod j=0 then f:=false
else j:=j+1;
end;
if f then write('*',i);
end;
end;
end.
Тестовое решение:
Введите число
2345
Число 2345 = 1*5*7*35*67