Другие языки программирования и технологии

помогите с задачей в C ++

Часть 3 - Преобразовать массив таким образом, чтобы сначала располагались все элементы массива, целая часть которых лежит в интервале [a,b], а потом – все остальные.( часть 1 и 2 -правильные)
// Илья_Машковцев_2011-12-02
#include <iostream>
#include <ctime>
using namespace std;
#define N 15

void main()
{
do
{
srand((unsigned) time(NULL));

double Array[N] = {0}, max = fabs(Array[0]), summa = 0;
bool flag = false;
int maxIndex = 0;

for (int n = 0; n < N; n++)
{
Array[n] = rand() % 10 + (double) rand() / 100000 - 4;
cout << "a[" << n << "] =\t" << Array[n] << endl;

if (fabs(Array[n]) > max)
{
max = fabs(Array[n]);
maxIndex = n;
}

if (flag == true)
{
summa += Array[n];
continue;
}

if (Array[n] >= 0)
flag = true;
}

int a, b;

cout << endl << " Input interval [a; b]: ";
cin >> a >> b;

int x, y;
double temp;

for (int n = 1; n < N; n++)
{
for (int m = N - 1; m > 0; m--)
{
x = Array[m];
y = Array[m - 1];

if ((x >= a && x <= b) && (y < a || y > b))
{
temp = Array[m];
Array[m] = Array[m - 1];
Array[m - 1] = temp;
}
}
}

for (int n = 0; n < N; n++)
cout << endl << "a[" << n << "] =\t" << Array[n];
cout << endl << "\n Index of maximum = " << maxIndex << endl << "\n Summa = " << summa;

fflush(stdin);
cin.get();
system("cls");
}
while (true);
}
ИА
Ихтиер Абдукадыров
92 840
Лучший ответ
int main()
{
int n;
cin >> n;
double *a=new double [n];
for (int i=0; i<n;>> a[ i ];
int m=0;
/*1*/
for (int i=1; i<n;>abs(a[m])) m=i;
cout << i;
double s=0;
int i=0;
/*2*/
while(a[ i ]<=0)
i++;
for(int j=i+1 ; j < n; j++)
s+=a[ i ];
cout << s;
3-е, если ты ещё не решил, могу написать.
МБ
Максим Б
2 238