Ventacademy
  • Socials
  • Business Fundamentals
    • Investments
  • High Income Skills
  • Programming
  • Software Review
  • Website Development
    • WordPress
    • Search Engine Optimization
    • Free Templates and Plugins
      • Support
  • Finance
No Result
View All Result
Knowledge base
No Result
View All Result
Home Support

c++ – I am not sure why I get this result

admin by admin
February 2, 2021
Share on FacebookShare on Twitter


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

void myfunction(int i)
{
    cout<<" "<<i;
};

void multiply(int a)
{
    a*2;
}

int main()
{
     int t[]={10,5,9,6,2,4,7,8,3,1};
    vector<int> v1(t,t+10);
    for_each(v1.begin(),v1.end(),multiply);
    iter_swap(v1.begin(), t+9);
    for_each(v1.begin(),v1.end(),myfunction);
    
    return 0;
}

Hello, I actually have question about this code.
when I run this, I see the result is 1 5 9 6 2 4 7 8 3 1 and I am not sure why the last element is still 1 even though I assigned the statement iter_swap(v1.begin(), t+9); in the middle.
I am the kind of beginner so I appreciate someone answer this question.
Thank you.

admin

admin

Related Posts

c++ – Why do STL algorithms require two iterators explicitly?

April 21, 2021

c++ – Can insert into vector Out of order?

April 21, 2021

c++ – Sorting the std::list of structures by rule

April 21, 2021

c++ – What does this line with comment mean?

April 21, 2021
Next Post

Nigeria's low-interest rate creates opportunities for these businesses

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recommended.

Fed Upbeat on Recovery, while Pledged to Maintain Stimulus Until Substantial Progress is Seen On Economy

April 8, 2021

EBITDA – DayTrading.com

January 14, 2021

Subscribe.

Trending.

No Content Available

About Us

Knowledge base

We bring you the best technology news, Finance news and lots more. you can download premium themes, plugins scripts, courses and lots more here.

Follow Us

Categories

  • All
  • Books
  • Business Fundamentals
  • Finance
  • Free Course
  • Free download
  • Free Templates and Plugins
  • Health
  • High Income Skills
  • Investments
  • NSFW
  • Photography
  • Search Engine Optimization
  • Software Review
  • Support
  • Technical Analysis
  • Website Development
  • Wordpress
  • World

Activity

FREEDOWNLOAD

Automatically generates native code for adding splash screens in Android and iOS

Vikinger 1.5.1 – BuddyPress and GamiPress Social Community

EduMall 2.7.1 – Professional LMS Education Center WordPress Theme

Admin Columns Pro – BuddyPress Addon 1.5.1

Microsoft Dynamics AX 2012 R3 Programming – Level 3 – Download Udemy Courses For Free

YITH Deals for WooCommerce Premium 1.0.21

Front End Web Design UX, CSS, FLEXBOX & SASS Complete Course – Download Udemy Courses For Free

Learn Python 3 programming | Become job ready using Pycharm – Download Udemy Courses For Free

Oxygen 5.9 – WooCommerce WordPress Theme

Preston 1.2.1 – Real Estate WordPress Theme

Support Board 3.2.4 – WordPress Chat Plugin

YITH WooCommerce Customize My Account Page 3.1.1 Nulled

YITH Cost of Goods for WooCommerce 1.2.13 Nulled

BoomBox 2.7.7 Nulled – Viral Magazine WordPress Theme

Calendarista 13.3 – Premium WordPress Booking Plugin

  • Socials
  • About
  • Advertise
  • Privacy & Policy
  • Contact

© 2020 Ventacademy

No Result
View All Result
  • Socials
  • Business Fundamentals
    • Investments
  • High Income Skills
  • Programming
  • Software Review
  • Website Development
    • WordPress
    • Search Engine Optimization
    • Free Templates and Plugins
      • Support

© 2020 Ventacademy