Está en la página 1de 2

UDO

TALLER DE LENGUAJES
VALOR 10 PTS

Problema 1 (3)

El valor de “n” será su fecha de nacimiento con formato DDMMAAAA

En mi caso sería 15111975


Corra paso a paso el siguiente problema recursivo

void PROGRAMA(int n) {
if (n < 2) {
System.out.println(n);
return;
} else {
PROGRAMA(n / 2);
System.out.println(n % 2);
return;
}
}

Problema 2 (7)

Escriba sub cedula + su fecha de nacimiento con formato DDMMAA

Ejemplo en mi caso; cedula= 7374987 mas mi fecha de nacimiento 151175

Formará 7374987151175
Arreglo[] =

0 1 2 3 4 5 6 7 8 9 10 11 12
7 3 7 4 9 8 7 1 5 1 1 7 5
En mi caso particular : Inicio será 0 y fin 12

Cada uno de ustedes ajuste el valor de fin según sus datos


UDO

TALLER DE LENGUAJES
VALOR 10 PTS

void quicksort(int arreglo[], int inicio, int fin)


{
int central, temporal, auxinicio, auxfin, medio;
if(fin-inicio > 1)
{
medio = (inicio + fin) / 2; central = arreglo[medio];
auxinicio = inicio; auxfin = fin; while(auxinicio<= auxfin)
{
while(arreglo[auxinicio] < central)
auxinicio++;
while(arreglo[auxfin] > central)
auxfin--;
if (auxinicio <= auxfin)
{temporal = arreglo[auxinicio];
arreglo[auxinicio] = arreglo[auxfin];
arreglo[auxfin] = temporal;
auxinicio++;
auxfin--;
}
}
quicksort(arreglo,inicio,auxfin);
quicksort(arreglo,auxinicio,fin);
}
else
if (fin -inicio==1)
if (arreglo[fin] < arreglo[inicio] )
{ temporal = arreglo[fin];
arreglo[fin] = arreglo[inicio];
arreglo[inicio] = temporal;
}
}

También podría gustarte