SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5.     int array[10000],i,n,j,swap;
  6.     int arr[10000];
  7.     scanf("%d", &n);
  8.     for (i=0;i<n;i++)
  9.     {
  10.         scanf("%d", &array[i]);
  11.  
  12.         arr[i]=i;
  13.     }
  14.     for (i=0;i<n-1;i++)
  15.     {
  16.         for (j=0;j<n-i-1;j++)
  17.         {
  18.             if (array[j]>array[j+1])
  19.             {
  20.                 swap = array[j];
  21.                 array[j] = array[j+1];
  22.                 array[j+1] = swap;
  23.  
  24.                 swap = arr[j];
  25.                 arr[j]=arr[j+1];
  26.                 arr[j+1]= swap;
  27.  
  28.             }
  29.  
  30.         }
  31.  
  32.     }
  33.  
  34.     for (i=0;i<n;i++)
  35.     {
  36.         printf("%d ",arr[i]);
  37.     }
  38.  
  39.     return 0;
  40. }
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