Chinaunix首页 | 论坛 | 博客
  • 博客访问: 391649
  • 博文数量: 199
  • 博客积分: 154
  • 博客等级: 入伍新兵
  • 技术积分: 1530
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-14 08:43
文章分类

全部博文(199)

文章存档

2015年(101)

2014年(97)

2011年(1)

分类: Python/Ruby

2014-10-16 12:28:49

# -*- coding: UTF-8 -*-
'''
【程序27】 
题目:利用递归函数调用方式,将所输入的5个字符,以相反顺序打印出来。
1.程序分析:
2.程序源代码:
'''
def output(s,l):
    if l==0:
       return
    print (s[l-1])
    output(s,l-1)
 
s = input('Input a string:')
l = len(s)
output(s,l)
C:
void py27()
{
void plain(int n);  
    int i=5;  
    plain(i);  
    printf("\n");
}


void plain(int n)  
{  
    char next;  
    if(n<=1)  
    {  
        next=getchar();  
        putchar(next);  
    }  
    else  
    {  
        next=getchar();  
        plain(n-1);  
        putchar(next);  
    }  
}  
阅读(792) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~