-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmtest.cpp
More file actions
41 lines (32 loc) · 850 Bytes
/
mtest.cpp
File metadata and controls
41 lines (32 loc) · 850 Bytes
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
#include <iostream>
#include <map>
#include <algorithm>
#include <sequtils.h>
using namespace std;
typedef map<string, float> StringFloatMap;
void print_stocks(StringFloatMap &stocks)
{
StringFloatMap::iterator pos;
for (pos = stocks.begin(); pos != stocks.end(); ++pos)
cout << "stock : " << pos->first << "\t\t"
<< "price : " << pos->second << endl;
cout << endl;
}
int main(int argc, char *argv[])
{
StringFloatMap stocks;
stocks["BASF"] = 369.0;
stocks["VW"] = 413.50;
stocks["Daimeler"] = 819.00;
stocks["BMW"] = 834.00;
stocks["Siemense"] = 842.20;
print_stocks(stocks);
StringFloatMap::iterator pos;
for (pos = stocks.begin(); pos != stocks.end(); ++pos)
pos->second *= 2;
print_stocks(stocks);
stocks["Volkswagan"] = stocks["VW"];
stocks.erase("VW");
print_stocks(stocks);
return 0;
}