#include <iostream>
#include <cmath>
#include <ctime>
using namespace std;
int main (void)
{
srand (time (0));
int Temp = 0;
int max = 1;
int maxi = 0;
int n = 0;
cout << "Input n = ";
cin >> n;
cout << endl;
int *A = new int[n];
for (int i = 0; i < n; i++)
A[i] = -10 + rand () % 30;
cout << A[i] << " ";
}
if (abs (A[i]) > abs (max))
max = A[i];
maxi = i;
cout << "\nABS(Max) = " << max << " Number = " << maxi;
Temp = A[n - 1];
A[n - 1] = max;
A[maxi] = Temp;
delete[]A;
Объяснение:
#include <iostream>
#include <cmath>
#include <ctime>
using namespace std;
int main (void)
{
srand (time (0));
int Temp = 0;
int max = 1;
int maxi = 0;
int n = 0;
cout << "Input n = ";
cin >> n;
cout << endl;
int *A = new int[n];
for (int i = 0; i < n; i++)
{
A[i] = -10 + rand () % 30;
cout << A[i] << " ";
}
for (int i = 0; i < n; i++)
{
if (abs (A[i]) > abs (max))
{
max = A[i];
maxi = i;
}
}
cout << "\nABS(Max) = " << max << " Number = " << maxi;
Temp = A[n - 1];
A[n - 1] = max;
A[maxi] = Temp;
cout << endl;
for (int i = 0; i < n; i++)
{
cout << A[i] << " ";
}
delete[]A;
}
Объяснение: