#include <iostream>
using std::cout;
using std::endl;
#include <cstdlib>
using std::rand;
using std::srand;
#include <ctime>
using std::time;
int main()
{
int a[10];
srand(time(0));
for(int i = 0; i < 10; i++)
{
a[i] = rand() % 201 - 100;
cout << a[i] << ' ';
}
cout << endl;
int temp;
for(int i = 0; i < 5; i++)
{
temp = a[i];
a[i] = a[i + 5];
a[i + 5] = temp;
}
for(int i = 0; i < 10; i++)
{
cout << a[i] << ' ';
}
cout << endl;
return 0;
}
B2=(10-2)/2=4
Т.к. все части одинаковы, C2=4
Из этого, C1=2
Проверим: A2=2-(-2)=4
<em>// PascalABC.NET 3.3, сборка 1583 от 25.11.2017</em>
<em>// Внимание! Если программа не работает, обновите версию!</em>
begin
var a:=SeqRandom(ReadInteger('n='),-99,99).Select(t->t/10).ToArray;
a.Println;
var (imax,imin):=(a.IndexMax,a.LastIndexMin);
Swap(a[imin],a[imax]); a.Println
end.
<u>Пример</u>
n= 15
-4.3 -5.6 7.2 -5.3 -7.7 9.3 1.4 0.3 -4.7 6.3 5.7 7.5 -8.6 6.9 -2.5
-4.3 -5.6 7.2 -5.3 -7.7 -8.6 1.4 0.3 -4.7 6.3 5.7 7.5 9.3 6.9 -2.5