太水了吧。。最大最小值求一下相减乘2完事了。。
#include<stdio.h>
int main()
{
int t;
scanf("%d", &t);
while (t--)
{
int min = 100, max = -1, n, pos;
scanf("%d", &n);
while (n--)
{
scanf("%d", &pos);
if (pos < min)
min = pos;
if (pos > max)
max = pos;
}
printf("%d\n", (max - min) * 2);
}
return 0;
}