mapping in C++
how do i map two numbers in C++ ?
i mean :
how do i do this ???
note: i cannot use a two dimensional array since i need to store values upto 10000 & i cannot create such a huge array(gcd)
any suggestions ??
Not sure, but would
do the work.
std::map<std::pair<int, int> > gcd;
oh..will have to read up about pair :D
thank u !
Another option would be to use math:
gcd[x * 10000 + y] - that will make a unique number in the 0..100000000 range, which can be used with map. It is possibly faster and easier than using a pair. But if the range grows much more than 10000, you'd struggle.
gcd[x * 10000 + y]
if x=10000 & y=10000 then array size would become too large ?
isn't it ?
No, not a regular large array, I meant to still use map, like this:
Originally Posted by jack_carver
gcd[300 *10000 + 432] = ...