|
-
June 3rd, 2012, 12:58 PM
#1
To form counter of N element
Hi,
Can anyone let me know how can i form a counter of say 30 elements so that to meet following requirement,
I need to access 5 elements out of 30 elements and out of these 5 elements once the one value is printed (i.e now access for remaining 4 element will be left) other one should get added immediately to this 5 element set, from remaining total 25 elements. In this way 5 element count will be there always.
I am trying this as follows, by forming vector of 30 elements accessing its 5 elements as,
for (iter = vector1.begin(); it < vector1.end();it++)
{
for(int count = 5; count >= 1 ; count--)
{
cout << "Print value<" <<count<<"> : "<< *it <<endl;
it++;
}
}
This displays 5 elements at a time but counter "count" waits for to finish off its remaining 4 elements however i want to maintain this counter to 5 elements always.
Appreciate any help in this.
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|