#include <stdio.h> #include <stdlib.h> void decrescente(int vet[], int size) { int i, j, old; for (i = 0; i < size; i++) { for (j = 0; j < size - 1; j++) { if (vet[j] < vet[j+1]) { old = vet[j]; vet[j] = vet[j+1]; vet[j+1] = old; } } } } void crescente(int vet[], int size) { int i, j, old; for (i = 0; i < size; i++) { for (j = 0; j < size - 1; j++) { if (vet[j] > vet[j+1]) { old = vet[j]; vet[j] = vet[j+1]; vet[j+1] = old; } } } } int main() { int vet1[15] = { 5,6,90,40,20,30,16,32,64,2048,4096,9,10,11,23 }; int vet2[15] = { 5,6,90,40,20,30,16,32,64,2048,4096,9,10,11,23 }; int vet3[15] = { 5,6,90,40,20,30,16,32,64,2048,4096,9,10,11,23 }; int vet4[15] = { 5,6,90,40,20,30,16,32,64,2048,4096,9,10,11,23 }; int i, j, old; for (i = 0; i < 15; i++) { for (j = 0; j < 15 - 1; j++) { if (vet1[j] < vet1[j+1]) { old = vet1[j]; vet1[j] = vet1[j+1]; vet1[j+1] = old; } } } printf("Decrescente: "); for (i = 0; i < 15; i++) printf("%d ", vet1[i]); printf("\n"); for (i = 0; i < 15; i++) { for (j = 0; j < 15 - 1; j++) { if (vet2[j] > vet2[j+1]) { old = vet2[j]; vet2[j] = vet2[j+1]; vet2[j+1] = old; } } } printf("Crescente: "); for (i = 0; i < 15; i++) printf("%d ", vet2[i]); printf("\n"); printf("\nPor funcao:\n"); crescente(vet3, 15); printf("Crescente: "); for (i = 0; i < 15; i++) printf("%d ", vet3[i]); printf("\n"); decrescente(vet4, 15); printf("Decrescente: "); for (i = 0; i < 15; i++) printf("%d ", vet4[i]); printf("\n"); return 0; }