Advertisement
dzieciol

Untitled

Mar 3rd, 2016
394
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6. int n,i,temp;
  7. printf("podaj liczbe elementow tablicy:");
  8. scanf("%d",&n);
  9. printf("wpisz poszczegolne elementy do posortowanaia (rosnaco):\n\n");
  10.  
  11. int tab[n],z=1;
  12.  
  13. for(i=0;i<n;i++){
  14. printf("podaj element %d:",i+1);
  15. scanf("%d",&tab[i]);
  16. }
  17. int j;
  18. for(j=n-1;j>0;j--){
  19. for(i=0;i<j;i++){
  20. if(tab[i]>tab[i+1]){
  21. temp=tab[i];
  22. tab[i]=tab[i+1];
  23. tab[i+1]=temp;
  24.  
  25. }
  26.  
  27. }
  28. }
  29.  
  30.  
  31.  
  32.  
  33.  
  34. printf("Wynik sortowania (rosnaco):\n");
  35. for (i=0;i<n;i++)
  36. printf("element nr%d:%d\n",i+1,tab[i]);
  37.  
  38.  
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement