Skip to content

Instantly share code, notes, and snippets.

@sandes
Created June 17, 2015 23:38
Show Gist options
  • Save sandes/1ed4be521060b9d14471 to your computer and use it in GitHub Desktop.
Save sandes/1ed4be521060b9d14471 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int *miny(int *v,int n){
int x=v[0],jmin=0;
for (int i=0; i<n; i++){
if(v[i]<x){
jmin=i;
x=v[jmin];
}
}
return &v[jmin];
}
void print(int *v,int n){
cout << "V: (";
for (int j=0; j<n; j++) cout << v[j] << " ";
cout << "), valor minimo: " << *miny(v,n) << endl;
}
int main(int argc, char *argv[]) {
int v[]={3,2,9,5,6};
int n = 5;
/*
multiplica por 2 el valor minimo
y el VM mostrado es el proximo minimo
*/
*miny(v,n)=2*(*miny(v,n));
print (v,n);
/**/
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment