What will be the output of the following C++ code? [code] #include <iostream> #include <algorithm> #include <vector> using

What will be the output of the following C++ code?
Code:
    #include <iostream>
    #include <algorithm>
    #include <vector>
    using namespace std;
    int main () 
    {
        vector<int> myvector;
        for (int i = 1; i < 6; ++i) 
            myvector.push_back(i);
        reverse(myvector.begin(), myvector.end());
        for (vector<int> :: iterator it = myvector.begin(); it != myvector.end(); ++it)
            cout << ' ' << *it;
        return 0;
    }
A. 1 2 3 4 5
B. 5 4 3 2 1
C. 0 1 2 3 4
D. 5 4 1 2 3
 

Tìm kiếm

Back
Top