最后一个检查点tle,救命

P1923 【深基9.例4】求第 k 小的数

Marc206721 @ 2024-12-04 19:11:52

#include<stdio.h>
#include<stdlib.h>
int comp(void* a,void*b){
    return *(int *)a-*(int *)b;
}
int main(){
    int n,d;
    scanf("%d %d",&n,&d);
    int a[n];
    for(int i=0;i<n;i++)
    scanf("%d",&a[i]);

    qsort(a,n,sizeof(a[0]),comp);

printf("%d",a[d]);

return 0;
}

by _4madeus @ 2024-12-08 10:51:15

@Marc206721qsort比sort慢,c语言得手敲


by Marc206721 @ 2024-12-08 17:14:15

@_4madeus ok,谢谢


|