wdmzjhyk @ 2024-11-26 20:51:58
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int s[10001];
void charu(int s[], int n)
{
for (int k = n / 2; k > 0; k /= 2)
{
for (int i = k; i < n; i++)
{
int c = s[i];
int j=i;
while (j >= k && s[j - k] > c)
{
s[j] = s[j - k];
j-=k;
}
s[j] = c;
}
}
}
int main()
{
int s[10001];
int a, b;
scanf("%d%d", &a, &b);
for (int i = 0; i < a; i++)
{
scanf("%d",&s[i]);
}
charu(s, a);
if (b >= 0 && b < a) {
printf("%d", s[b]);
}
return 0;
}
by zzz13579zzz @ 2024-11-26 20:55:25
n
by wdmzjhyk @ 2024-11-26 21:02:16
@zzz13579zzz 改了之后会有两个超时,看来希尔排序不行,我再去试试别的,谢谢大佬