-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IteratorsBabcock.cpp
40 lines (37 loc) · 1.02 KB
/
IteratorsBabcock.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*********************************
* Name: Using Iterators
* Author: Tanner Babcock
* Created: August 25, 2022
* Course: CIS 152 - Data Structures
* Version: 1.0
* OS: Void GNU/Linux
* Complexity: O(1)
* IDE: Vim
* Copyright : This is my own original work based
* on specifications issued by our instructor.
* Academic Honesty: I attest that this is my original
* work. I have not used unauthorized source code,
* either modified or unmodified. I have not given
* other fellow student(s) access to my program.
*********************************/
#include <iostream>
#include <iterator>
#include <vector>
#include <ctime>
#include <cstdlib>
using namespace std;
int main(void) {
vector<int> collection;
vector<int>::iterator ptr;
const int TOTAL = 10;
srand(time(NULL));
for (int x = 0; x < TOTAL; x++) {
collection.push_back((rand() % 20) + 5);
}
int y = 0;
for (ptr = collection.begin(); ptr != collection.end(); advance(ptr, 1)) {
cout << "collection[" << y << "] = " << collection[y] << endl;
y++;
}
return 0;
}