Recursive implementation of string inverse permutation it's not a good way, and it's not advocating it. This is the only way to get a deeper look at recursion:
Example: Do not use library function implementation, recursive implementation of string reverse arrangement
#include <stdio.h> #include <stdlib.h> #include <assert.h>int my_strlen (char const *STR) {assert (str) ; int len = 0;while (*str) {len++;str++;} return Len;} char* reverse (char *string) {char Tmp;int len = My_strlen (String), char *left = String;char *right = string + len-1;if (*s Tring) {tmp = *left;*left = *right;*right = ' + '; reverse (string + 1); *right = tmp;} return string;} int main () {char arr[50];scanf ("%s", arr), Char *ret=reverse (arr);p rintf ("%s\n", arr); System ("pause");
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/7F/16/wKiom1cTDuejCidIAACZM0Mgkr0648.png "title=" Untitled. png "alt=" Wkiom1ctduejcidiaaczm0mgkr0648.png "/>
return 0;
}
This article is from the "11132019" blog, please be sure to keep this source http://11142019.blog.51cto.com/11132019/1764709
Recursive implementation of strings in reverse order