题解 | #整数与IP地址间的转换#

整数与IP地址间的转换

https://www.nowcoder.com/practice/66ca0e28f90c42a196afd78cc9c496ea

t1=list(map(eval,input().split('.')))
t2=eval(input())
temp=''
t=''
for i in range(4):
    temp=str(bin(t1[i])).replace('0b','')
    while len(temp)<8:
        temp='0'+temp
    t+=temp+''
print(int(t,2))
t2=str(bin(t2)).replace('0b','')
while len(t2)%8!=0:
    t2='0'+t2
t=''
for i in range(0,len(t2),8):
    temp=str(int(t2[i:i+8],2))
    t=t+temp+'.'
print(t[:-1])

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-10 11:45
你不要过来啊啊啊啊啊啊啊
码农索隆:对面:“今天你不面也得面”
点赞 评论 收藏
分享
陈逸轩1205:才105 哥们在养生呢
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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