Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- int arr[]={-5,4,0,22,-3,0,5,7,-4,-8};
- int i=0,j=0,t,n=10;
- while(arr[i]<0)
- i++;
- j=i;
- i++;
- for(;i<n;i++){
- if(arr[i] < 0){
- t = arr[i];
- arr[i] = arr[j];
- arr[j] = t;
- j++;
- }
- }
- i=j;
- while(arr[i]==0)
- i++;
- j=i;
- i++;
- for(;i<n;i++){
- if(arr[i] == 0){
- t = arr[i];
- arr[i] = arr[j];
- arr[j] = t;
- j++;
- }
- }
- for(i=0;i<n;i++)
- printf("%d\t",arr[i]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement