int t; if(k>n) return 0; for(int i = 0; i<n; i++) { if(i >= k-1) { t = d; d = a[i]; a[i] = t; } } a[i] = d;