Please help

https://www.codechef.com/problems/MXCH
QUESTION LINK
MY SOLUTION

#include //assume iostream is imported cant write it in the post somehow
using namespace std;

int main()
{
// your code goes here
int t,n,k;
std::cin>>t;
while(t–>0)
{
std::cin>>n>>k;
int a1[n];
int a2[k+1];
int i,c=0;
for(i=0;i<n;i++)
a1[i] = (i+1);

    if(k==0)
    {
        a2[0]=n;
        std::cout<<a2[0]<<" ";
        for(i=0;i<n-1;i++)
        std::cout<<a1[i]<<" ";
        break;
    }
    else
    {
        i=1;
        a2[0]=a1[0];
        a2[k]=a1[n-1];
        while(i<=k-1)
        {
            a2[i]=a1[i];
            i++;
        }
        c=i;
    }
    for(i=0;i<=k;i++)
    std::cout<<a2[i]<<" ";
    for(;c<n-1;c++)
    std::cout<<a1[c]<<" ";
    std::cout<<endl;
}
return 0;

}