Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- void insertion(int a[],int n)
- {
- int i,j,temp;
- for(i=0; i<n-1; i++)
- {
- for(j=0; j<n-1-i; j++)
- {
- if(a[j]>a[j+1])
- {
- temp=a[j];
- a[j]=a[j+1];
- a[j+1]=temp;
- }
- }
- }
- }
- int main()
- {
- int i,j,n,temp,a[10];
- scanf("%d",&n);
- for(i=0; i<n; i++)
- {
- scanf("%d",&a[i]);
- }
- insertion( a, n);
- for(i=0; i<n; i++)
- {
- printf("%d ",a[i]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement