// PascalABC.NET
begin
// 1
var s11 := SeqRandom(100, 10, 99).Sum;
var s12 := ArrRandom(100, 10, 99).Sum;
case Sign(s11 - s12) of
-1: Println('Сумма второго массива больше');
0: Println('Суммы равны');
else
Println('Сумма первого массива больше')
end;
// 2
var s21 := SeqRandom(1000, -9, 9).Sum;
var s22 := ArrRandom(1000, -9, 9).Sum;
var s23 := ArrRandom(1000, -9, 9).Sum;
if s21 > s22 then
Swap(s21, s22);
if s22 > s23 then
Swap(s22, s23);
Swap(s21, s22)
Println(s21, s22, s23);
// 3
var a := ArrRandom(50, -99, 99);
a.Println;
var s31 := a.Where(p -> p > 30);
Print('Количество', s31.Count, ' сумма', s31.Sum)
end.
#include <iostream>
using namespace std;
int main()
{
int *arr;
int size;
cout << "size = ";
cin >> size;
if (size <= 0) {
cerr << "Invalid size" << endl;
return 1;
}
arr = new int[size];
for (int i = 0; i < size; i++) {
cout << "arr[" << i << "] = ";
cin >> arr[i];
int temp;
for (int i = 0; i < size - 1; i++) {
for (int j = 0; j < size - i - 1; j++) {
if (arr[j] > arr[j + 1]) {
temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
cout << arr[i] << " ";
cout << endl;
delete [] arr;
return 0;
// PascalABC.NET
begin
// 1
var s11 := SeqRandom(100, 10, 99).Sum;
var s12 := ArrRandom(100, 10, 99).Sum;
case Sign(s11 - s12) of
-1: Println('Сумма второго массива больше');
0: Println('Суммы равны');
else
Println('Сумма первого массива больше')
end;
// 2
var s21 := SeqRandom(1000, -9, 9).Sum;
var s22 := ArrRandom(1000, -9, 9).Sum;
var s23 := ArrRandom(1000, -9, 9).Sum;
if s21 > s22 then
Swap(s21, s22);
if s22 > s23 then
begin
Swap(s22, s23);
if s21 > s22 then
Swap(s21, s22)
end;
Println(s21, s22, s23);
// 3
var a := ArrRandom(50, -99, 99);
a.Println;
var s31 := a.Where(p -> p > 30);
Print('Количество', s31.Count, ' сумма', s31.Sum)
end.
#include <iostream>
using namespace std;
int main()
{
int *arr;
int size;
cout << "size = ";
cin >> size;
if (size <= 0) {
cerr << "Invalid size" << endl;
return 1;
}
arr = new int[size];
for (int i = 0; i < size; i++) {
cout << "arr[" << i << "] = ";
cin >> arr[i];
}
int temp;
for (int i = 0; i < size - 1; i++) {
for (int j = 0; j < size - i - 1; j++) {
if (arr[j] > arr[j + 1]) {
temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
for (int i = 0; i < size; i++) {
cout << arr[i] << " ";
}
cout << endl;
delete [] arr;
return 0;
}