How to shift the character within the string in c? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

How to shift the character within the string in c?

ex: input: abc output : cab bca abc

12th Mar 2018, 9:16 AM
Jai Ganez
Jai Ganez - avatar
1 ответ
+ 2
Umm, I would imagine char arr[] = "abc"; int i,j; for (i = 0; i < 3; i++) { for (j = 0; j < 3 - 1; j++) { char temp = arr[j+1]; arr[j+1] = arr[j]; arr[j] = temp; } printf("%s\n", arr); }
12th Mar 2018, 10:24 AM
Hatsy Rei
Hatsy Rei - avatar