#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
int arr[n];
int i;
for(int f=0; f<n; f++)
{
scanf("%d", &arr[f]);
}
int y=0;
for(i=0; i<n; i++) //바퀴 반복
{
for(int j=0; j<n-1-i; j++) //비교활동 반복
{
if(arr[j] > arr[j+1])
{
int t; // 임시 저장
t=arr[j];
arr[j] = arr[j+1];
arr[j+1] = t;
y=i;
}
}
}
printf("%d", y+1);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: