十六进制转十进制:十六的幂

s=list((input()))

if s[0]=="0" and s[1]=="x":

del s[0:2]

j=len(s)

z=[]

for i in s:

j=j-1

if j>0:

try:

m=int(i)

z.append(m*16**j)

except ValueError :

if i=="A":

z.append(10*16**j)

elif i=="B":

z.append(11*16**j)

elif i=="C":

z.append(12*16**j)

elif i=="D":

z.append(13*16**j)

elif i=="E":

z.append(14*16**j)

elif i=="F":

z.append(15*16**j)

if j==0:

try:

l=int(i)

z.append(l)

except ValueError :

if i=="A":

z.append(10)

elif i=="B":

z.append(11)

elif i=="C":

z.append(12)

elif i=="D":

z.append(13)

elif i=="E":

z.append(14)

elif i=="F":

z.append(15)

print(int(sum(z)))

全部评论

相关推荐

牛客41406533...:回答他在课上学,一辈子待在学校的老教授用三十年前的祖传PPT一字一句的讲解,使用谭浩强红皮书作为教材在devc++里面敲出a+++++a的瞬间爆出114514个编译错误来学这样才显得专业
点赞 评论 收藏
分享
11-07 15:54
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务