Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void main(){
  4.  
  5. //Declaración de variables
  6. float array[20]={2,7,3,5,7,2,4,6,8,3,4,6,3,4,9,3,6,8,0,2};
  7. int i;
  8. int j;
  9. int canvi;
  10. printf("Array: ");
  11.  
  12. for(i=0;i<20;i++){
  13. printf("%.f / ",array[i]);
  14. }
  15.  
  16. printf("\n\nArray ordenado: ");
  17.  
  18. for (i = 0; i < 20 - 1; i++){
  19. for(j = i + 1; j < 20; j++){
  20. if (array[i] > array[j]) {
  21. canvi = array[i];
  22. array[i] = array[j];
  23. array[j] = canvi;
  24. }
  25. }
  26. }
  27.  
  28. for(i=0;i<20;i++){
  29. printf("%.f / ",array[i]);
  30. }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement