Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define SIZE 10
- //sort by choice:find smallest on first iteration, put it into index 0, second - index 1...
- int main()
- {
- int place,temp,i,j,k,arr[SIZE]={9,5,7,3,2,6,8,4,1,0};
- for(i=0;i<SIZE;i++)printf("%d\t",arr[i]);//print array
- for(i=0;i<SIZE-1;i++)//place to put max number
- {printf("\ni=%d\n",i);place=SIZE-i;
- for(j=i+1;j<SIZE;j++)
- {printf("j=%d\t",j);
- if(arr[i]>arr[j])
- temp=arr[i],arr[i]=arr[j],arr[j]=temp;
- }//for j
- printf("\n");
- for(k=0;k<SIZE;k++)printf("%d\t",arr[k]);//print array'
- printf("\n");
- if(i==SIZE-2)i=SIZE;
- }//for i
- for(i=0;i<SIZE;i++)printf("%d\t",arr[i]);//print array
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement