Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #bubblesort
- clc;
- printf("Elo witaj w babylsort\r\n");
- i=1;
- tab=[];
- do
- tab(i)=input("Podaj liczbę, lub 0 aby zakończyć:");
- i=i+1;
- until(tab(i-1)==0)
- allElements = size(tab,2);
- printf("Liczba elementów: %d\n",allElements);
- for (i=1:1:allElements)
- innerLoopElements = allElements-i;
- for (j=i:1:innerLoopElements)
- if(tab(j)>tab(j+1))
- temp=tab(j); tab(j)=tab(j+1); tab(j+1)=temp;
- endif
- end
- end
- printf("Posortowane liczby:\r\n");
- printf("%d, ",tab);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement