#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;
1) program ex1;uses crt;var a, b: integer;begin readln(a, b); if a > b then begin a:= a * 2; b:= b + 5; end else begin a:= a - 5; b:= b - 5; end; write(a, b);end.
2) program ex1;uses crt;var a, b, c: integer;begin readln(a, b, c); if (a + b > c) and (a + c > b) and (b + c > a) then writeln('Треугольник существует') else writeln('Треугольник не существует'); if (a = b ) and (b = c) then writeln('Треугольник равносторонний') else if (a = b) or (b = c) or (a = c) then writeln('Треугольник равнобедренный') else writeln('Треугольник разносторонний');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;
}
program ex1;uses crt;var a, b: integer;begin readln(a, b); if a > b then begin a:= a * 2; b:= b + 5; end else begin a:= a - 5; b:= b - 5; end; write(a, b);end.
2)
program ex1;uses crt;var a, b, c: integer;begin readln(a, b, c); if (a + b > c) and (a + c > b) and (b + c > a) then writeln('Треугольник существует') else writeln('Треугольник не существует'); if (a = b ) and (b = c) then writeln('Треугольник равносторонний') else if (a = b) or (b = c) or (a = c) then writeln('Треугольник равнобедренный') else writeln('Треугольник разносторонний');end.