Created
December 14, 2012 14:50
-
-
Save mgarciaisaia/4285964 to your computer and use it in GitHub Desktop.
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 <stdlib.h> | |
#include <stdio.h> | |
void main(void) { | |
int numeros[15]; | |
int i = 0; | |
numeros[i++] = 0; | |
numeros[i++] = 1; | |
numeros[i++] = 2; | |
numeros[i++] = 0; | |
numeros[i++] = 0; | |
numeros[i++] = 1; | |
numeros[i++] = 2; | |
numeros[i++] = 0; | |
numeros[i++] = 0; | |
numeros[i++] = 0; | |
numeros[i++] = 1; | |
numeros[i++] = 2; | |
numeros[i++] = 0; | |
numeros[i++] = 0; | |
int j = 0; | |
int aux; | |
int k; | |
for(k=0; k<1; k++) { | |
printf("Iteracion %d\n", k + 1); | |
for(j=0; j<i-2; j++) { | |
if(numeros[j]==numeros[j+1]) { | |
printf("En numeros[%d]=%d cambio numeros[%d]=%d por numeros[%d]=%d\n", j, numeros[j], j+1, numeros[j+1], j+2, numeros[j+2]); | |
aux = numeros[j + 1]; | |
numeros[j+1] = numeros[j+2]; | |
numeros[j+2] = aux; | |
} | |
} | |
for(j=0; j<i; j++) { | |
printf("%d, ", numeros[j]); | |
} | |
printf("\n\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment