SHARE
TWEET

not done, wtf?

Lisaveta777 Feb 14th, 2020 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #define SIZE 10
  3. //sort array by modules
  4.  
  5. int main()
  6. {
  7.     int i, j, arr[SIZE]={10, -1, 7, -3, 8,-9,-2,6,4,-5};
  8.    
  9.     for(i=0;i<SIZE;i++)
  10.     printf("%d\t",arr[i]);
  11.     printf("\n\n");
  12.    
  13.     for(i=0;i<SIZE-1;i++)
  14.     {
  15.         for(j=i+1;j<SIZE;j++)
  16.         {
  17.             int t;
  18.             if((arr[i]>0 &&arr[j]>0&&arr[i]>arr[j]))
  19.             t= arr[i],arr[i]= arr[j],arr[j]=t, printf("h ");
  20.            
  21.             else if((arr[i]<0 &&arr[j]<0&&arr[i]<arr[j]))
  22.             t= arr[i],arr[i]= arr[j],arr[j]=t,printf("o ");
  23.              //printf("%d\t",arr[i]);
  24.              
  25.              //for(i=0;i<SIZE;i++)
  26.              //printf("%d\t",arr[i]);
  27.            
  28.         }
  29.     }
  30.     for(i=0;i<SIZE;i++)
  31.     printf("%d\t",arr[i]);
  32.  
  33.     return 0;
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top