题面
Write a recursive version of the function reverse(s)
, which reverses the string in place.
Write a program to enter a string and call reverse(s)
.
See also Exercise 4-13 in the textbook
#include <stdio.h>
#include <string.h>
/***************************************************************/
/* */
/* DON'T MODIFY main function ANYWAY! */
/* */
/***************************************************************/
void reverse(char s[]) {
// TODO: your function definition
}
#define MAXLINE 80 /* maximum input line length */
int main() {
char s[MAXLINE];
scanf("%s", s);
//********** reverse is called here *************
reverse(s);
//**************************************************
printf("%s", s);
}
样例
输入
ecnu
输出
unce