• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need help with Bitset

 
vidu mayur
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This program sorts the numbers in a string array by using a bitset provided the numbers are unique. The program keeps track of which numbers have been seen by setting bits in a bitset.
The output is printed by visiting all the elements in the bit set. The output should be like this:
In sorted order: 2 9 10 21 43 45 52 66 68 71 87
This is the problem. I am not able to give the upper limit while accessing the elements in the bitset. I have given an arbitrary number 100 for now and the program is working. Is there any way to access the last element in the bitset.

Thanks in advance
 
chi Lin
Ranch Hand
Posts: 348
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try change
for (j = 0; j < 100; j++){ ... }
to
for (j = 0; j < sortSet.size(); j++){ ... }
 
vidu mayur
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
It works perfectly now.
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic