首页 > 代码库 > 题目238-小明的调查统计-nyoj20140804

题目238-小明的调查统计-nyoj20140804

#include <stdio.h>
int main()
{
    int T,a[100];
    scanf("%d",&T);
    while(T--)
    {
        int n,i,j,sum,t;
        scanf("%d",&n);
        for(i=0;i<n;i++)
        scanf("%d",&a[i]);
        for(j=0;j<n-1;j++)
        {
            for(i=0;i<n-1-j;i++)
            {
                if(a[i]>a[i+1])
                {t=a[i];a[i]=a[i+1];a[i+1]=t;}
                }
            }
            sum=a[n-1]-a[0];
            printf("%d\n",sum);
        }
        return 0;
    }