U E D R , A S I H C RSS

Reverse And Add/태훈

~cpp # -*- coding: cp949 -*-
def reverse(source):
    i=0
    n=''
    r=''
    n=source

    print n
    #print type(n)
    for i in range(len(str(n))):
        #print len(str(n))-i
        n=str(n)
        r = r + n[len(str(n))-i-1]
    return r

def hap(n):
    r=''
    r=reverse(n)
    r=int(r)
    n=int(n)    
    if decide(n+r) == 1:
        #print n+r
        return n+r
    else:
        #print hap(n+r)
        return hap(n+r)

def decide(n):
    if n == int(reverse(n)):
        print '끝났셈!! : ' + n
        return 1
    
if __name__ == '__main__':
    n = raw_input('입력하셈 >> ')
    print hap(n)

    


        
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:27:55
Processing time 0.0086 sec