#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;
#
# https://pastebin.com/Nasemc0T
#
# Python 3.x
# 1.
# Для теста возьмем конкретную матрицу 8x8.
matrix=[[-35, 115, -45, -25, 1, 83, 13, 53], [119, 128, 31, 124, 66, 126, 63, -1], [-21, 86, 120, 68, 149, 65, -42, 107], [108, 112, 96, 25, 99, 9, 140, 89], [51, 99, 68, 80, 26, 74, 105, -6], [92, 82, 22, 54, 11, 87, -2, -42], [26, -21, 129, 85, 97, 101, 106, 96], [10, -7, -28, 96, 115, 57, -25, 77]]
# Эквивалентно .flatten() для numpy матрицы.
array=list()
for row in matrix: array=array + row
maximum=max(array)
print("#1. Maximum: ", maximum)
# 2.
file="test.txt"
with open(file) as fp:
amount=int(fp.readline())
array=list()
for _ in range(amount):
digit=int(fp.readline())
array.append(digit)
# конец двойно табуляции
maximum=max(array)
print("#2. Maximum: ", maximum)
#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;
}