@TheMachinist
244 / 176 / 15
Регистрация: 14.06.2010
Сообщений: 422
|
08.11.2010, 02:38
|
|
C++ | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| #include <iostream>
#include <algorithm> // stable_partition()
using namespace std;
bool IsPositive(int x) {return x > 0;}
const int N = 20;
int main()
{
int Arr[N];
for(int i = 0;i < N;i++){
Arr[i] = (rand()%10) - 5;
cout << Arr[i] << " ";}
cout << "\n\n";
std::stable_partition(Arr, Arr+N,IsPositive);
for(int i = 0;i < N;i++)
cout << Arr[i] << " ";
system("pause");
} |
|
1
|