Quote:
Originally Posted by bigearsbilly
homework eh?
at least try something.
|
Hello,
I am sorry, but I dont understand what are you tried to say.
Homework??? at least, ten years or more last time when I have opened a book to study.
I have try some code, but it is to insert all variables in a list.
Code:
#include <iostream>
#include <map>
#include <utility> // make_pair
using namespace std;
int main()
{
typedef map<char, int> mapType;
mapType myMap;
// insert elements using insert function
myMap.insert(pair<char, int>('a', 1));
myMap.insert(pair<char, int>('b', 2));
myMap.insert(pair<char, int>('c', 3));
myMap.insert(mapType::value_type('d', 4)); // all standard containers provide this typedef
myMap.insert(make_pair('e', 5)); // can also use the utility function make_pair
// erase the first element using the erase function
mapType::iterator iter = myMap.begin();
myMap.erase(iter);
// output the size of the map
cout << "Size of myMap: " << myMap.size() << '\n';
cout << "Enter a key to search for: ";
char c;
cin >> c;
// find will return an iterator to the matching element if it is found
// or to the end of the map if the key is not found
iter = myMap.find(c);
if( iter != myMap.end() )
cout << "Value is: " << iter->second << '\n';
else
cout << "Key is not in myMap" << '\n';
// clear the entries in the map
myMap.clear();
}
but it is very hard to handle several variables.
Then, I have look for information about it, and I dont find clear information (tcl_getvar of tcl library, but I dont know if I can use it)
And now, I am here, to look for help, but I see that it is very hard to find it.
And know in my language, No se por que te pones asi o por que me saltas con eso de que si son "homework". Me parece que la respuesta esta fuera de contexto y no tengo ganas de discutir con nadie.
Best regards