
1条回答 默认 最新
CSDN专家-link 2021-11-19 10:46关注逆序的方法是分别从首尾开始进行字符交换,直到中间
#include <stdio.h> int count(char *s) { int i=0,c=0; while(s[i++] != 0) c++; return c; } void revert(char *s) { int len = count(s); int i=0,j=len-1; char c; while(i<j) { c = s[i]; s[i] = s[j]; s[j] = c; } } int main() { char s[1000]; gets(s); revert(s); printf("%s",s); return 0; }本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报 编辑记录