How to implementing spiral pattern in string

the string is circular. Direction of the spiral is clockwise inward.
where n = 2 , m = 4 , k =3 which is string size and k length string s
input
2 4 3
abc

output
abca
bacb

the output should print in matrix form

I can do something like this, if I understood your question correct

int index = 0;
for(int i = 0; i < n; i++){
	for(int j = 0; j < m; j++){
		cout<<s[index];
		index = (index + 1) % k;
	}
	cout<<"\n";
}

1 Like

if input will be
4 8 6
abcdef

output will be

abcdefab
bcdefabc
abafedcd
fedcbafe

it will print in spiral pattern

I didn’t get the pattern, can you explain more ?