Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2020
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <windows.h>
  4.  
  5. int main()
  6. {
  7. int liczby[100],i,j,tmp;
  8. srand(time(NULL));
  9.  
  10. for(i=0; i<100; i++)
  11. {
  12. *(liczby+i)=rand()%101;
  13. }
  14. printf("Przed posortowaniem\n:");
  15. for(i=0; i<100; i++)
  16. {
  17. printf("%d\n",*(liczby+i));
  18. }
  19.  
  20.  
  21. for(j=0; j<99; j++)
  22. {
  23. for(i=0; i<99-j; i++)
  24. {
  25. if(*(liczby+i)>*(liczby+i+1))
  26. {
  27. tmp=*(liczby+i);
  28. *(liczby+i)=*(liczby+i+1);
  29. *(liczby+i+1)=tmp;
  30. }
  31. }
  32. }
  33. printf("Po posortowaniu:\n");
  34. for(i=0; i<100; i++)
  35. {
  36. printf("%d\n",*(liczby+i));
  37. }
  38.  
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement