首页
题库
面试
求职
学习
竞赛
More+
所有博客
搜索面经/职位/试题/公司
搜索
我要招人
去企业版
登录 / 注册
首页
>
试题广场
>
IP地址转化
[编程题]IP地址转化
热度指数:900
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 256M,其他语言512M
算法知识视频讲解
IP地址是一个用 '.' 隔开的四段数字,每段的大小是
。请你把 IP 地址转换成一个整数。(IPv4)
例如, 114.55.207.244 的二进制表示是 01110010 00110111 11001111 11110100 ,其十进制表示是 7590617063
示例1
输入
"114.55.207.244"
输出
"1916260340"
示例2
输入
"0.0.0.1"
输出
"1"
马上挑战
算法知识视频讲解
提交运行
算法知识视频讲解
添加笔记
求解答(0)
邀请回答
收藏(11)
分享
纠错
提交结果有问题?
6个回答
7篇题解
开通博客
姐姐的遮阳伞
发表于 2022-04-09 18:54:18
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param ip string字符串 * @r
展开全文
面向对象的小白很愉快
发表于 2022-12-10 13:12:38
先将其转成二进制,再通过二进制转成unsigned int,再将unsigned int 转成char*,然后返回
牛客724172947号
发表于 2022-08-16 23:10:28
//对部分输入字符格式先做异常校验,然后满足条件的数据做对应移位转换 public String IPtoNum (String ip) { // write code here  
展开全文
fred-coder
发表于 2022-03-08 19:46:40
Python 十进制转2进制高位补0 "{:08b}".format(val) # # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param ip string字符串 # @return string字符串 # class Solution:
展开全文
高大的斑马不想打工
发表于 2023-09-20 18:09:48
不要被题目迷惑了,直接计算就行了。 public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param ip string字符串 * @return
展开全文
终将成为大佬
发表于 2024-03-24 19:49:02
#include <algorithm> #include <iterator> #include <string> class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的
展开全文
叮叮当咚
发表于 2024-02-28 16:39:17
#include <cstddef> #include <cstdint> #include <sstream> #include <string> class Solution { public: /** * 代码中的类名、方法名、
展开全文
问题信息
字符串
模拟
难度:
6条回答
11收藏
2261浏览
热门推荐
通过挑战的用户
查看代码
苏皖
2022-09-15 18:46:04
好20110
2022-09-15 12:42:44
maple-s...
2022-09-14 14:27:15
牛客46766...
2022-09-13 19:41:19
孙利showshow
2022-09-11 11:47:17
相关试题
一个文件里有10万个随机正整数,按...
去哪儿
堆
模拟
评论
(4)
有两个文件context.txt和...
去哪儿
模拟
评论
(4)
一个10*10的矩阵(可以理解为棋...
去哪儿
模拟
评论
(0)
之前的经历中单品数据分析的经验丰富...
评论
(1)
2022 诺瓦科技 Perl re...
perl
System Verilog
评论
(1)
扫描二维码,关注牛客网
意见反馈
下载牛客APP,随时随地刷题
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param ip string字符串 * @return string字符串 */ public String IPtoNum (String ip) { // write code here } }
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param ip string字符串 * @return string字符串 */ string IPtoNum(string ip) { // write code here } };
#coding:utf-8 # # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param ip string字符串 # @return string字符串 # class Solution: def IPtoNum(self , ip ): # write code here
using System; using System.Collections.Generic; class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param ip string字符串 * @return string字符串 */ public string IPtoNum (string ip) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param ip string字符串 * @return string字符串 */ function IPtoNum( ip ) { // write code here } module.exports = { IPtoNum : IPtoNum };
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param ip string字符串 # @return string字符串 # class Solution: def IPtoNum(self , ip: str) -> str: # write code here
package main //import "fmt" /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param ip string字符串 * @return string字符串 */ func IPtoNum( ip string ) string { // write code here }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param ip string字符串 * @return string字符串 */ char* IPtoNum(char* ip ) { // write code here }
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param ip string字符串 # @return string字符串 # class Solution def IPtoNum(ip) # write code here end end
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param ip string字符串 * @return string字符串 */ def IPtoNum(ip: String): String = { // write code here } }
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param ip string字符串 * @return string字符串 */ fun IPtoNum(ip: String): String { // write code here } }
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param ip string字符串 * @return string字符串 */ public String IPtoNum (String ip) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param ip string字符串 * @return string字符串 */ export function IPtoNum(ip: string): string { // write code here }
public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param ip string字符串 * @return string字符串 */ func IPtoNum ( _ ip: String) -> String { // write code here } }
struct Solution{ } impl Solution { fn new() -> Self { Solution{} } /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param ip string字符串 * @return string字符串 */ pub fn IPtoNum(&self, ip: String) -> String { // write code here } }
"114.55.207.244"
"1916260340"
"0.0.0.1"
"1"