Guest User

Untitled

a guest
Jan 16th, 2019
56
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <time.h>
  4. #include <stdlib.h>
  5.  
  6. void main(){
  7. int arr[20], i=0,j=0,canvi=0;
  8. srand(time(NULL));
  9. int r;
  10. for(i=0;i<20;i++){
  11. arr[i]=rand () % 100;
  12. }
  13. printf("Este es el array original [ ");
  14. for(i=0;i<20;i++){
  15. printf("%d ",arr[i]);
  16. }
  17. printf("]");
  18. for(i=0;i<19;i++){
  19. for(j=i+1;j<20;j++){
  20. if(arr[i]>arr[j]){
  21. canvi=arr[i];
  22. arr[i]=arr[j];
  23. arr[j]=canvi;
  24. }
  25. }
  26. }
  27. printf("\n\n\nEste es el array final [ ");
  28. for(i=0;i<20;i++){
  29. printf("%d ",arr[i]);
  30. }
  31. printf("]");
  32. }
RAW Paste Data