#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;
// с циклом while var s,i:integer; begin i:=100; while i<=999 do begin if i mod 77 = 0 then s:=s+i; i:=i+1; end; writeln('Сумма трехзначных кратных 77: ',s); 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;
}
//c циклом for
var s,i:integer;
begin
for i:=100 to 999 do
if i mod 77 = 0 then s:=s+i;
writeln('Сумма трехзначных кратных 77: ',s);
end.
Тестовое решение:
Сумма трехзначных кратных 77: 5929
// с циклом while
var s,i:integer;
begin
i:=100;
while i<=999 do begin
if i mod 77 = 0 then s:=s+i;
i:=i+1;
end;
writeln('Сумма трехзначных кратных 77: ',s);
end.