代码一:

#include<stdio.h>
#include<string.h>

void reverse(char *s){
    if(strlen(s)>0)
    {
        printf("%c ",s[strlen(s)-1]);
        s[strlen(s)-1]='\0';
        reverse(s);
    }
}
int main()
{
    char s[80];
    gets(s);
    reverse(s);
}

代码二:

#include <stdio.h>
#include <stdlib.h>

void print() {
    char a;
    scanf("%c", &a);
    if ( a!='#' ){
        print();
    }
    if( a!='#' ){
        printf("%c",a);
    }
}
int main()
{
    print();
    return 0;
}

效果:

 

 

用递归的方法实现字符串的反序输出

 

相关文章:

  • 2021-12-16
  • 2021-12-18
  • 2022-12-23
  • 2021-10-20
  • 2022-12-23
  • 2021-06-15
  • 2021-10-15
猜你喜欢
  • 2022-12-23
  • 2021-10-14
  • 2022-12-23
  • 2022-12-23
  • 2021-09-03
  • 2021-07-04
  • 2022-12-23
相关资源
相似解决方案