Skip to content

Instantly share code, notes, and snippets.

@aldajo92
Created May 25, 2017 15:18
Show Gist options
  • Save aldajo92/c2e8ceda3f83e33409c9876615a3719e to your computer and use it in GitHub Desktop.
Save aldajo92/c2e8ceda3f83e33409c9876615a3719e to your computer and use it in GitHub Desktop.
ExampleVector.c
#include <iostream>
#include <string>
#include <vector>
#include <stdlib.h>
using namespace std;
void operation(vector<int> nv){
int contador=0;
for (int i=0; i<nv.size(); i){
contador=contador+1;
if(nv[i]> 0){
i=nv[i];
cout<< i<<endl;
}
else
break;
}
cout<<contador;
}
int main()
{
int A[]={1,4,-1,3,2};
vector<int> nv (A, A + sizeof(A) / sizeof(int) );
operation(nv);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment