利用递归函数调用方式,将所输入的五个字符,以相反顺序打印出来

递归

 

void palin(int n);
int main()
{
int i=5;


printf("please input 5 numbers:");
palin(i);
printf("\n");

}
void palin(int n)

{
char next;
if(n<=1)
{
next=getchar();
printf("\n");
putchar(next);

}
else
{
next=getchar();
palin(n-1);
putchar(next);
}
}

对于putchar(),getchar()的用法

 

https://www.jb51.net/article/126855.htm

posted @ 2018-07-28 14:48  黑大帅gs  阅读(4575)  评论(0编辑  收藏  举报