ordenar un vector
//de menor a mayor
void ordenar(int v[], int size){
int i, j, aux;
//ALGORITMO DE BURBUJA
for (i = 0; i < size - 1; i++){
for (j = i + 1; j < size; j++){
if(v[i] > v[j]){
aux = v[i];
v[i] = v[j];
v[j] = aux;
}
}
}
printf("\n");
for(int i = 0; i <= size - 1; i++){
printf("vector[%d]: %d\n", i, v[i]);
}
}
//de mayor a menor
void ordenar_mayor_menor(int *v, int tam){
int i, j, aux;
for(i = 1; i < tam; i++){
for(j = tam - 1; j >= i; j--){
if(v[j] > v[j-1]){
aux = v[j];
v[j] = v[j-1];
v[j-1] = aux;
}
}
}
}
Also in C:
- how to run a update comand in linux
- cannot update windows 10
- vector aleatorio sin repetir
- strcat in c
- c null define
- c print long
- pygame detect click
- how to read space separated words in c
- method abstraction
- check if string starts with c
- counter program in c language
- get range of values in mongodb
- c fork wait for child
- vbnet create and write on file
- array addition and multiplication in c
- struct Node** head_ref
- sleep in c programming
- error: lvalue required as left operand of assignment
- c program to find number of days in a month using switch case
- c flip variable
- sdl audio
- arduino server read
- printf("%3d ",XX);
- dining philosophers problem in c