当前位置:网站首页>1108. IP address invalidation
1108. IP address invalidation
2022-06-09 10:08:00 【Mr Gao】
1108. IP Address invalidation
Give you an effective IPv4 Address address, Go back to this IP Invalid version of address .
The so-called invalidation IP Address , In fact, it is to use “[.]” Instead of every “.”.
Example 1:
Input :address = “1.1.1.1”
Output :“1[.]1[.]1[.]1”
Example 2:
Input :address = “255.100.50.0”
Output :“255[.]100[.]50[.]0”
This question is also very simple , We set up a 3*strlen(address) Memory auxiliary string array , It can solve the problem well , Be careful , Finally, set the string array s[end]=‘\0’, This is very important .
The solution code is as follows :
char * defangIPaddr(char * address){
int len=strlen(address);
char *s =(char*)malloc(sizeof(char)*3*len);
int i=0;
int j=0;
while(address[i]!='\0'){
if(address[i]=='.'){
s[j++]='[';
s[j++]='.';
s[j++]=']';
}
else{
s[j++]=address[i];
}
i++;
}
s[j]='\0';
return s;
}
边栏推荐
- MSF practice - harm of ms17-010 vulnerability
- Kubernetes第七篇:Pod进阶、Controller进阶、Resource和Dashboard
- Machine learning notes - create confusion matrix using scikit learn
- How to achieve compliant telecommuting?
- 数字图像处理 图解边缘检测在图像理解中的作用
- openstack详解(十三)——Glance Keystone设置与启动
- 构建词表与抽样——【torch学习笔记】
- 【实战技能】从《Beautiful Teams》一书看团队
- [technology, business and management] drama learning and Entrepreneurship: Silicon Valley season 5 Episode 1-3
- openstack详解(十一)——openstack Glance服务理论知识
猜你喜欢

MSF模块查找详解

Extensions attribute of TS generics

【科技、商业和管理】看剧学创业:《硅谷》第六季第1-2集

【genius_platform软件平台开发】第一万零一讲:电力项目dz产品windows环境vs2017编译遇到的报错汇总

Openstack explanation (13) -- Grace keystone setup and startup

【科技、商業和管理】看劇學創業:《矽穀》第五季第4-6集

WebService service call
![[practical skills] inspiration from ai/ml of Google i/o 2022 Conference for developers](/img/1d/523177bc3b94aa0fef8d554e793e70.png)
[practical skills] inspiration from ai/ml of Google i/o 2022 Conference for developers

DNMAP架构实现和扫描实战

Redis集群实例内存使用率飙升排查
随机推荐
Linear independence, orthogonal basis and orthogonal matrix
MSF tips
Notes on the development of raspberry pie (15): Raspberry pie 4b+ compile and install MySQL database from the source code
LeetCode_ Binary tree_ Prefix and_ Medium_ 437. path sum III
数字图像处理 图解图像恢复任务
机器学习之房屋租赁价格预测:探索型数据分析+特征工程+建模+报告
Redis info command memory information description
Moral and regulatory knowledge of data science
16. 最接近的三数之和-快速排序加双指针法
Changan chain chainmaker multi machine environment
How to achieve compliant telecommuting?
[linear algebra] understand eigenvalues and eigenvectors
当你孤独,抑郁,焦虑的时候......请记得,还有风雨
MSF实战——MySQL空密码的危害
MSF backdoor attack against FTP
MSF information collection based on TCP protocol
[5 machine learning] the most understandable decision tree in the whole network (with source code attached)
Openstack explanation (XI) -- openstack grace service theoretical knowledge
机器学习笔记 - R语言学习入门系列一
C # introductory series (IX) -- method use