Created
May 25, 2017 15:18
-
-
Save aldajo92/c2e8ceda3f83e33409c9876615a3719e to your computer and use it in GitHub Desktop.
ExampleVector.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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