Advertisement
Guest User

Untitled

a guest
Jul 30th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include<stdio.h>
  2. int main(){
  3.  
  4. int s,temp,i,j,a[10001],k,c=0;
  5.  
  6.  
  7. scanf("%d",&s);
  8.  
  9.  
  10. for(i=1; i<=s; i++)
  11.  scanf("%d",&a[i]);
  12.  
  13.  
  14. for(i=1; i<=s; i++)
  15. {
  16.  for(j=1; j<s; j++)
  17.  {
  18.       if(a[j]>a[j+1])
  19.         {
  20.           temp=a[j];
  21.          a[j]=a[j+1];
  22.          a[j+1]=temp;
  23.          c++;
  24. }
  25. }
  26. }
  27. printf("%d\n",c);
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement