[STL] reverse

STL/변경 가능 시퀀스 알고리즘 2010. 5. 17. 15:41 Posted by zetz
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <algorithm>
#include <cassert>
using namespace std;
 
int main()
{
    cout<< "Using reverse_copy, a copying version of the"
        << " generic reverse algorithm." << endl;
 
    int a[1000], b[1000];
    int i;
    for (i=0; i< 1000; ++i)
        a[i] = i;
 
    reverse_copy(&a[0], &a[1000], &b[0]);
 
    for (i=0; i< 1000; ++i)
        assert(a[i] == i && b[i] == 1000 - i - 1);
    cout<< " --- Ok." << endl;
 
    return 0;
}

'STL > 변경 가능 시퀀스 알고리즘' 카테고리의 다른 글

[STL] search  (0) 2010.05.17
[STL] rotate  (0) 2010.05.17
[STL] replace  (0) 2010.05.17
[STL] remove  (0) 2010.05.17
[STL] random_shuffle  (0) 2010.05.17