I have wrote a small map test program which is below:
void main()
{
vector<double> price;
vector<string> time;
price.push_back(5.70);
price.push_back(5.77);
price.push_back(5.81);
price.push_back(5.72);
price.push_back(5.81);
time.push_back("10:40");
time.push_back("10:43");
time.push_back("10:44");
time.push_back("10:46");
time.push_back("10:48");
map<double,string> myMap;
for (int i=0 ; i<price.size() ; i++)
{ myMap[price[i]] = time[i]; }
for (int i=0 ; i<price.size() ; i++)
{
if (price[i] == 5.81)
{ cout << myMap[price[i]] << endl; }
}
}
My expect outputs should be:
10:44
10:48
But the outputs I get is :
10:48
10:48
I don't know why it is wrong.