Yurttas/PL/OOL/Cplusplus/F/07/05/01/f 00.cpp

From ZCubes Wiki
Jump to navigation Jump to search
 1/*
 2   Copyright(C) 2002
 3   All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
 4
 5   Permission to use, copy, modify, and distribute this
 6   software and its documentation for EDUCATIONAL purposes
 7   and without fee is hereby granted provided that this
 8   copyright notice appears in all copies.
 9
10   date   : June 1, 2002.
11   author : Salih Yurttas.
12
13   f_00.cpp
14*/
15
16
17#include <iostream>
18#include <iterator>
19#include <algorithm>
20#include <vector>
21
22using namespace std;
23
24int main(int argc, char* argv[]) {
25
26  vector< vector<int> > vv;
27
28  int a[] = {3, 1, 5, 2, 4, 6, 8, 7};
29
30  vector<int> v(a, a+8);
31
32  cout << "1. --" << endl;
33
34  int n = v.size();
35  for(int i=0; i<n; i++)
36    cout << v.at(i) << endl;
37  cout << endl;
38
39  vv.push_back(v);
40
41  n = v.size();
42  for(int i=n-1; i>=0; i--)
43    v.at(i) += v.at(1);
44
45  cout << "2. --" << endl;
46
47  n = v.size();
48  for(int i=0; i<n; i++)
49    cout << v.at(i) << endl;
50  cout << endl;
51
52  vv.push_back(v);
53
54  cout << "3. --" << endl;
55
56  n = vv.size();
57  
58  for(int i=0; i<n; i++) {
59    sort(vv.at(i).begin(),
60         vv.at(i).end());
61
62    copy(vv.at(i).begin(),
63         vv.at(i).end(),
64         ostream_iterator<int>(cout, "\n"));
65    cout << endl;
66  }
67
68}