This is the loop.
for(m=0; m<10; m++){
for (i=0; i<=K; i++) {
A[i] = i;
}
}
And this is print code.
System.out.println("A:");
for (i=0; i<20; i++) {
System.out.printf("%.1s\t", A[i]);
if (i==9) System.out.println();
}
If user enter K as 3 then result is:
A:
0 1 2 3 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
But it should be like
A:
0 1 2 3 0 1 2 3 0 1
2 3 0 1 2 3 0 1 2 3