and when i define long long int a[maxnodes][maxnodes] i get size of a is too large ...(compile error)...Code:# define maxnodes 20000
is there any way to solve this
and when i define long long int a[maxnodes][maxnodes] i get size of a is too large ...(compile error)...Code:# define maxnodes 20000
is there any way to solve this
Yes, 20000 x 20000 is 381M entries, times 8 makes it about 3 GB, which is more than what a user-mode application in windows can do.
You probably will need to use a sparse matrix or some such.
More later - got a train to catch.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
yes i know....
well am asking any other stl will solve this issue?
i know map can solve single dimensional thing...but here it is 2 -d... i need 2 keys to map to a value....
any other approach plz
Allocate on the heap using new, or make a vector of vectors.
can u explain me in detail tabstop... will be helpful with the syntax
That wont stop him from trying to use about 3GB on a 32-bit machine and failing.
dpp: Your only option is to explain in enough detail exactly what you plan on storing in this 2D array, and what the whole thing is for. Also comment on whether you need to store a value in every 'cell' of this 2D array.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
The obviously easy solution is to go out and buy a machine with about 6GB of RAM, and install a 64-bit OS.
Beyond that, the other solution is a sparse matrix, but that ONLY works if there are large gaps in the matrix. With no gaps, then you have no option.
Obviously, if you could use long instead of long long, that would halve the size, and it may fit within the limits.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
well the scenario is i scan a few i/ps n number of times
not all the positions will be valued in the array...Code:while(x>5) { cin>>a>>b; array[a][b]=1 }
a and b can be atmost the value i specified in the first post
So, if you only ever store a one in the position, why do you need to have unsigned long long array? A char or bool array would work just as well, and take up much less space.
Sorry, but if you are not telling us the whole story, we can only help you with the bits you tell us, so if array[a][b] = 1 is not what ACTUALLY goes on, then that's obviously changing the above advice.
The other option is of course to not do this using an array at all, but by simply storing the a & b values somehow.
How you solve this will very much depend on what you are actually trying to achieve in overall terms.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Do you need all of the data in memory at one time? If not make a stream buffer for cin, do your logic test and then throw away the data.
Last edited by Phyxashun; 03-03-2009 at 01:44 PM.