May 21, 2014 at 7:47pm UTC
Here is a simple program that I got as an exercise from my book. I get the following error when I run it:
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
// Keyboard keys \ |
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include "Screen.h"
#include "Person.h"
#include "Sales_data.h"
using std::cout; using std::cerr; using std::endl; using std::cin;
using std::ifstream; using std::ofstream;
using std::istringstream; using std::ostringstream;
using std::string; using std::vector; using std::list; using std::deque;
int main()
{
int is[] = { 0, 1, 1, 2, 3, 5, 8, 13, 21, 55, 89 };
vector<int > vi;
list<int > li;
for (auto elem : is) {
vi.push_back(elem);
li.push_back(elem);
}
auto begvi = vi.begin();
while (begvi != vi.end()) {
if (*begvi % 2) {
vi.erase(begvi);
}
else
++ begvi;
}
auto begli = li.begin();
while (begli != li.end()) {
if (*begli % 2 != 0) {
li.erase(begli);
}
else
++begli;
}
for (auto elem : vi) {
cout << elem << " " ;
}
cout << endl;
for (auto elem : li) {
cout << elem << " " ;
}
cout << endl;
return 0;
}
Last edited on May 21, 2014 at 7:52pm UTC
May 21, 2014 at 7:56pm UTC
Last edited on May 21, 2014 at 7:56pm UTC