UVA 299 - Train Swapping

Problem PDF

Solution:

#include
int main()
{
    int i,j,k,t,n,b,a[100],c;
    scanf("%d",&t);
    for(k=1;k<=t;k++)
    {
    c=0;
    scanf("%d",&n);
    for(i=0;i=i;j--)
            if(a[j-1]>a[j])
                {
                c++;
                b=a[j-1];
                a[j-1]=a[j];
                a[j]=b;
                }
    printf("Optimal train swapping takes %d swaps.\n",c);
    }
return 0;
}
https://github.com/Shipu/OnlineJudgeProblemSolutionWithCPlusPlus/tree/master/uva/299/299.cpp