Reverse in place · 原地反转
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · 此页面需较新浏览器(支持 SharedArrayBuffer)。请升级 Chrome、Edge、Firefox 或 Safari 至最新版本。
English
Reverse in place
Reverse a C-string in place — change the characters in the same array rather than building a new string. The classic move: a left index at the start and a right index at the end, swap them, then step both toward the middle until they meet.
中文
原地反转
原地反转 C 字符串 —— 直接修改同一个数组里的字符,而不是新建字符串。经典做法:一个左下标在开头,一个右下标在结尾,交换它们,然后两个下标都向中间移动,直到相遇。
Complete void reverse_in_place(char *s) to reverse the C-string s in place (modify the same array). Do not write main. · 完成 void reverse_in_place(char *s),原地反转 C 字符串 s(修改同一个数组)。不要写 main。
Click Run to see the output here. · 点击“运行”查看此处输出。