Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- int n,i,temp;
- printf("podaj liczbe elementow tablicy:");
- scanf("%d",&n);
- printf("wpisz poszczegolne elementy do posortowanaia (rosnaco):\n\n");
- int tab[n],z=1;
- for(i=0;i<n;i++){
- printf("podaj element %d:",i+1);
- scanf("%d",&tab[i]);
- }
- int j;
- for(j=n-1;j>0;j--){
- for(i=0;i<j;i++){
- if(tab[i]>tab[i+1]){
- temp=tab[i];
- tab[i]=tab[i+1];
- tab[i+1]=temp;
- }
- }
- }
- printf("Wynik sortowania (rosnaco):\n");
- for (i=0;i<n;i++)
- printf("element nr%d:%d\n",i+1,tab[i]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement