Python逆序打印正整数,递归,不使用全局变量
>>> def reverse(x):
str=chr(x%10+ord('0'))
if(x>=10):
x=(int)(x/10)
str+=reverse(x)
return str;
>>> reverse(123)
'321'
Python逆序打印正整数,递归,不使用全局变量
>>> def reverse(x):
str=chr(x%10+ord('0'))
if(x>=10):
x=(int)(x/10)
str+=reverse(x)
return str;
>>> reverse(123)
'321'