HDU 1673 Optimal Parking

http://acm.hdu.edu.cn/showproblem.php?pid=1673

阅读题

View Code
#include <stdio.h>
#include <stdlib.h>
int cmp(const void*a,const void*b)
{
    return *(int*)a-*(int*)b;
}
int main()
{
    int t,n,i;
    int x[30];
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        for(i=0;i<n;i++)
            scanf("%d",x+i);
        qsort(x,n,sizeof(int),cmp);
        printf("%d\n",(x[n-1]-x[0])*2);
    }
    return 0;
}
原文地址:https://www.cnblogs.com/xiaohongmao/p/2455977.html