t*i 发帖数: 72 | 1 Could someone explain the program to me.
void ret_str(char* s)
{
if(*s != '\0')
ret_str(s+1);
cout<<*(s);
}
int main()
{
ret_str("born2c0de");
return 0;
} |
r*******y 发帖数: 290 | 2 recursive call = a stack, which is FILO = reverse
【在 t*i 的大作中提到】 : Could someone explain the program to me. : void ret_str(char* s) : { : if(*s != '\0') : ret_str(s+1); : cout<<*(s); : } : int main() : { : ret_str("born2c0de");
|
c********x 发帖数: 84 | 3 void ret_str(char* s)
{
if(*s != '\0')
ret_str(s+1);
cout<<*(s);
}
int main()
{
ret_str("b"); // ask yourself what would happen
ret_str("bo"); // ask again
...
ret_str("born2c0de");
return 0;
} |
s****u 发帖数: 118 | 4 有才
【在 c********x 的大作中提到】 : void ret_str(char* s) : { : if(*s != '\0') : ret_str(s+1); : cout<<*(s); : } : int main() : { : ret_str("b"); // ask yourself what would happen : ret_str("bo"); // ask again
|