Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- using namespace std;
- #define tamano 10
- int busquedaBinariaEnVectorV ( int v[], int n, int clave, int pri){
- /* Aca va el codigo de la busqueda binaria */
- int posic= -1;
- pri=1;
- int u=n-1;
- int pos;
- bool enc;
- while ((pri <= u) and (pos == -1)){
- int m=(pri +u)/2;
- if(v[m]==clave){
- pri =m+1;
- } else if(v[m] < clave) {
- pri =m+1;
- } else {
- u=m-1;
- }
- }
- return posic;
- }
- int cargarSinRepetirEnVector ( int v[], int n, int clave){
- int u = n-1;
- bool enc = true;
- int posic = BusquedaBinariaEnVectorV(v, n, clave); // el ultimo parametro no hace nada
- if(posic != -1){
- return true;
- } else if(posic == -1){
- enc = false;
- posic = pri;
- for(j = u; j < pri; j--) {
- v[j+1]=v[j];
- }
- v[pri]=clave;
- n++;
- return false;
- }
- }
- int main(){
- return 0;
- }
- ----------------------------------------------------------------------------------------------------------------
- #include <iostream>
- using namespace std;
- int ordenarVectorShell(int v[], int n){
- int K=0;
- int I=0;
- int J=0;
- int n=10
- double intervalo = (double)n/2;
- while (intervalo > 0){
- for (i=intervalo +1; i<n; i++){
- while(j>0){
- k=j+intervalo;
- if(v[j]<=v[k]){
- j=-1;
- }else{
- swap (v[j], v[k]);
- j=j-intervalo;
- }
- }
- }
- }
- }
- ---------------------------------------------------------------------------------------------------------------------
- #include <iostream>
- using namespace std;
- #define MAX_FIL 30
- int ordenarVectorInserion(int v[], int n){
- for(i=1; i<n-1; i++){
- int j= i;
- aux=v[i];
- while((j>0) and (aux<v[j-1])){
- v[j]=v[j-1];
- j--;
- }
- v[j]=aux;
- }
- }
- #include <stdio.h>
- #define tamano 10
- int ordenarVectorBurbuja ( int v[], int n)
- {
- for (i=1; i<u-1;i++){
- if( v[j] > v[j+1] ){
- int aux= v[j];
- v[j]=v[j+1];
- v[j+1]=aux;
- }
- }
- return ;
- }
- int main(){
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement