#include <iostream> // universalc.cpp
using namespace std; int main() // rextester.com/DHHKPJ12975
{ setlocale (LC_ALL, "RUS");
srand(time(NULL)); int i,j; int n=5;
int d[n], x[n], a[n][n], y[n][n],temp;
cout << "Массив d в строку" << endl;
for (i=0; i<n; i++)
{ d[i] = rand() % 9; cout << d[i] << " ";
}
cout << "\n \nМассив d чётные x=d^2" << endl;
for (i=0; i<n; i++)
{ if (d[i] %2 ==0) x[i] = d[i] * d[i];
else x[i]=d[i];
cout << d[i] << " " << x[i] << endl;
}
cout << "\nМассив x сортировка" << endl;
for (i=0; i<n-1; i++) for (j = i+1; j<n; j++)
if (x[i]>x[j]) { temp=x[i]; x[i]=x[j]; x[j]=temp;}
cout << "и вывод x через while\n" << endl;
i=0; while (i < n)
{ cout << x[i] << " "; i++; }
cout << "\n\nМассив y сумма или нечётная y=d^2" << endl;
for (i=0; i<n; i++)
{ for (j = 0; j<n; j++)
{ a[i][j]=i+j;
if (a[i][j] %2 !=0) y[i][j] = a[i][j] * a[i][j];
else y[i][j] = a[i][j];
cout << y[i][j] << "\t"; }
cout << endl; }
cout << "\nМассив d минимакс от:" << endl;
for (i=0; i<n; i++) cout << d[i] << " ";
cout << "\n";
int min = d[0]; int max = d[0]; int nmin=0; int nmax=0;
for (i=1; i<n; i++)
{ if (d[i]< min) { min=d[i]; nmin=i;}
if (d[i]> max) { max=d[i]; nmax=i;}
}
cout << min << " " << nmin << "\t" << max << " " << nmax;
cout << "\n\nСумма d и средний" << endl;
double s=0; for (i=-1; i<n-1; s += d[++i]);
cout << s << "\t" << s/n << "\n";
system("pause");
}