#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;
}
На Python, C#(просто код без обязательной конструкции) и C++(просто код, без int main, iostream и т.п.)
Объяснение:
Python:
a = int(input())
if a > 0:
print("Greater")
elif a< 0:
print("Lower")
else:
print("Zero")
C#:
int a = convert.ToInt32(Console.ReadLine());
if(a > 0) {
Console.WriteLine("Greater");
}
else if(a < 0) {
Console.WriteLine("Lower");
}
else {
Console.WriteLine("Zero");
}
C++:
using namespace std;
...
int a;
cin >> a;
if(a > 0) {
cout << "Greater" << endl;
}
if(a < 0) {
cout << "Lower" << endl;
}
if(a == 0) {
cout << "Zero" << endl;
}