#include<stdio.h>
int main()
{
int n,i,j,count=0;
scanf("%d\n",&n);
char arr[n+9];
gets(arr);
for(i=0;i<n-1;i++){
for(j=0;j<n-1-i;j++)
{if(arr[j]>arr[j+1])
{int temp;
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}count++;
}}
printf("%d\n",count);
/* unsigned long long a,b,c;
scanf("%d%d%d",&a,&b,&c);
if(a%c!=0&&b%c!=0)
printf("%d",(a/c+(a%c)/(a%c))*(b/c+(b%c)/(b%c)));
else{if(a%c!=0&&b%c==0)
printf("%d",(a/c+(a%c)/(a%c))*(b/c));
else if(a%c==0&&b%c!=0)
printf("%d",(a/c)*(b/c+(b%c)/(b%c)));
else printf("%d",(a/c)*(b/c));
}*/
return 0;
}
标签:10.20,b%,arr,a%,temp,count,printf From: https://blog.51cto.com/u_15758636/5780577