#include <stdio.h>
void reverse( const char *const sPtr );
int main( void )
{
char sentence[ 80 ];
printf( "Enter a line of text: " );
gets( sentence );
printf( "\nThe line printed backward is:\n" );
reverse( sentence );
return 0;
}
void reverse( const char *const sPtr )
{
if( sPtr[0]=='\0' ){
return;
}
else {
reverse( &sPtr[ 1 ] );
putchar( sPtr[ 0 ] );
}
}
比如我输入We!输出的是 !eW,但过程理解不了,是否可以详细讲解下这个递归过程,谢谢
|
|