NOJ/73/main.c

21 lines
364 B
C
Raw Normal View History

2020-08-31 16:46:43 +00:00
#include <stdio.h>
int main(void){
int number, i, n[1024];
scanf("%d",&number);
for(i = 0; i < number; i++) scanf("%d",&n[i]);
int if_ch = 1, tmp, count = 0;
while(if_ch){
if_ch = 0;
for(i = 0; i < number; i++)
if(n[i] > n[i+1]){
tmp = n[i];
n[i] = n[i+1];
n[i+1] = tmp;
if_ch = 1, count++;
}
}
printf("%d\n",count);
return 0;
}