@BilalMuakkit/

pushback

C++

No description

fork
loading
Files
  • main.cpp
  • main
main.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cstdlib>

using namespace std;


int main() 
{
 // create vector
 vector<int>::const_iterator ITER;
 cout << "Creating a list of scores. ";
 vector<int> scores;
 scores.push_back(1500);
 scores.push_back(2500);
 scores.push_back(4200);

 cout << "\nHIGH SCORES:\n";
 for(ITER = scores.begin(); ITER != scores.end(); ++ITER)
 cout << *ITER << endl;
 

 //randomize values 
 cout << "\nRandomizing Scores:  \n";
 srand(time(0));
 random_shuffle(scores.begin(), scores.end());
 for(ITER = scores.begin(); ITER != scores.end(); ++ITER)
 cout << *ITER << endl;

// sort
cout << "\nSorting Scores:\n";
sort(scores.begin(), scores.end());
//need to include a beggining and end point
for(ITER = scores.begin(); ITER != scores.end(); ++ITER)
 cout << *ITER << endl;

 //create 
 cout << "\nCreating another set of scores.\n";
 vector<int> moreScores;
 moreScores.push_back(2000);
 moreScores.push_back(2200);
 moreScores.push_back(8500);

 cout << "\n More High Scores:\n";
 for(ITER = moreScores.begin(); ITER != moreScores.end(); ++ITER)
cout << *ITER << endl;
//use
cout << "\nUsing both lists.\n";
vector<int>allScores(6);//create
merge(scores.begin(), scores.end(), moreScores.begin(),
moreScores.end(), allScores.begin());
for(ITER = allScores.begin(); ITER != allScores.end(); ++ITER)
cout << *ITER << endl;
}