Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- void swap(int *a, int *b)
- {
- int temp =*a;
- *a = *b;
- *b = temp;
- }
- void bubblesort(int s[], int n)
- {
- int k,m;
- for(k=0;k<n-1;k++)
- {
- for(m=0;m<n-k-1;m++)
- {
- if(s[m]>s[m+1])
- {
- swap(s[m],s[m+1]);
- }
- }
- }
- }
- int main()
- {
- int i,j,i_max=0,s[100];
- char c[100];
- scanf("%s",&c);
- i_max=strlen(c);
- for(i=0,j=0;i<i_max;i+=2,j++)
- {
- s[j]=c[i]-48;
- }
- s[j]='\0';
- bubblesort(s,i_max);
- for (i=0;i<(i_max+1)/2;i++)
- {
- printf("%d ",s[i]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement