#include<stdio.h>
int main()
{
int n, k, p=0, a[100]={0}, left, right, b, c;
//n是输入的数的总数,k为所选作为基准的数是第几个
scanf_s("%d%d", &n, &k);
getchar();
for (int i = 0; i < n; i++)
{
scanf_s("%d", &a[i]);
}
p = a[k - 1];
left = 0;
right = n - 1;
while (a[left] != p && a[right] != p)
{
for (left = 0; left < n; left++)
{
if (a[left] >= p)
{
b = a[left];
break;
}
else
{
left++;
}
}
for (right = n - 1; right >= 0; right--)
{
if (a[right] < p)
{
c = a[right];
break;
}
else { right--; }
}
a[left] = c; a[right] = b;
}
if (left == right + 1)
{
for (int i = 0; i < n; i++)
{
printf("%d", a[i]);
}
}
return 0;
}
//请问我这代码运行不了,在这基础上要怎么改才能运行?又具体是哪里出了问题?能不能直接在源码上解决了发给我
//麻烦各位了,感激不尽!下面是具体题目