Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7490943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:47:37+00:00 2026-05-29T15:47:37+00:00

i have a vector of vector mydata. i want to iterate my data in

  • 0

i have a vector of vector “mydata”. i want to iterate my data in negative direction. the iterator should be started from the middle to the beginning.
i wish to use following way;

vector<vector<int> >::const_iterator points;
int i, k;

(lets assume k = 10)

for (i=k, points=mydata.begin()+k; i != -1; i--, points--){

     //do stuff
}

does this way is the proper way to iterate in backward? (I am using dev c++, so predicates and some modern commands cant be used.)
Hope your suggestions to do this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T15:47:38+00:00Added an answer on May 29, 2026 at 3:47 pm

    Since it’s vector, you dont need to use iterator at all:

    for (int k = 4; k >= 0; k--)
    {
        // do something with v[k]
    }
    

    Example:

    #include <iostream>
    #include <vector>
    using namespace std;
    
    int main(int argc, char** argv)
    {
        int arr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
        vector<int> v(arr, arr + 10);
    
        for (int k = 4; k >= 0; k--)
        {
            cout << v[k] << endl;
        }
    }
    

    output:

    5
    4
    3
    2
    1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a std::vector, namely vector<vector<vector> > > mdata; i want pass data from
I have a vector<set<char> > data structure (transactions database) and I want to know
I have a vector of IntRect: vector. How can I iterate from both ends
I have a data.frame called mydata and a vector ids containing indices of the
I have a vector of beans that holds information I want to display in
I have a vector of booleans. I need to set its elements from n-th
I have a vector of pointers to objects. I'd like to remove objects from
Suppose I have some data stored in a container of unique_ptr s: struct MyData
I have some data that is stored in a sorted vector. This vector is
I have a Vector of Object[] type that stores my data. How to print

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.