OpenJudge/Poj 2105 IP Address
1.链接地址:
http://poj.org/problem?id=2105
http://bailian.openjudge.cn/practice/2105
2.题目:
IP Address
Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 18146 Accepted: 10456 Description
Suppose you are reading byte streams from any device, representing IP addresses. Your task is to convert a 32 characters long sequence of '1s' and '0s' (bits) to a dotted decimal format. A dotted decimal format for an IP address is form by grouping 8 bits at a time and converting the binary representation to decimal representation. Any 8 bits is a valid part of an IP address. To convert binary numbers to decimal numbers remember that both are positional numerical systems, where the first 8 positions of the binary systems are:27
26
25
24
23
22
21
20
128 64 32 16 8 4 2 1Input
The input will have a number N (1<=N<=9) in its first line representing the number of streams to convert. N lines will follow.Output
The output must have N lines with a doted decimal IP address. A dotted decimal IP address is formed by grouping 8 bit at the time and converting the binary representation to decimal representation.Sample Input
4
00000000000000000000000000000000
00000011100000001111111111111111
11001011100001001110010110000000
01010000000100000000000000000001Sample Output
0.0.0.0
3.128.255.255
203.132.229.128
80.16.0.1Source
3.思路:
4.代码:
#include "stdio.h"
#include "stdlib.h" int f(char input[],int start)
{
int ans=;
int i;
for(i=;i<;i++)
{
ans=ans*+(input[i+start]-'');
}
return ans;
}
int main()
{
int a,b,c,d;
int n;
int i;
char input[];
scanf("%d\n",&n);
for(i=;i<n;i++)
{
gets(input);
a=f(input,);
b=f(input,);
c=f(input,);
d=f(input,);
printf("%d.%d.%d.%d\n",a,b,c,d);
}
//system("pause");
return ;
}
OpenJudge/Poj 2105 IP Address的更多相关文章
- poj 2105 IP Address
IP Address Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 18951 Accepted: 10939 Desc ...
- poj 2105 IP Address(水题)
一.Description Suppose you are reading byte streams from any device, representing IP addresses. Your ...
- IP Address 分类: POJ 2015-06-12 19:34 12人阅读 评论(0) 收藏
IP Address Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 19125 Accepted: 11053 Desc ...
- poj2105 IP Address(简单题)
题目链接:id=2105">http://poj.org/problem?id=2105 ----------------------------------------------- ...
- ERROR 2003 (HY000): Can't connect to MySQL server on 'ip address' (111)的处理办法
远程连接mysql数据库时可以使用以下指令 mysql -h 192.168.1.104 -u root -p 如果是初次安装mysql,需要将所有/etc/mysql/内的所有配置文件的bind-a ...
- oracle 11g RAC安装节点二执行结果错误CRS-5005: IP Address: 192.168.1.24 is already in use in the network
[root@testdb11b ~]# /u01/app/oraInventory/orainstRoot.sh Changing permissions of /u01/app/oraInvento ...
- Assign an Elastic IP Address to Your Instance
By default, an instance in a nondefault VPC is not assigned a public IP address, and is private.You ...
- Ubuntu setup Static IP Address
Change Ubuntu Server from DHCP to a Static IP Address If the Ubuntu Server installer has set your se ...
- How to configure a static IP address on CentOS 7(CentOS7静态IP地址设置)
Question: On CentOS 7, I want to switch from DHCP to static IP address configuration with one of my ...
随机推荐
- jQuery操作select option
jQuery获取Select选择的Text和Value: 1. var checkText=jQuery("#select_id").find("option:selec ...
- OpenCV 读取.xml文件
OpenCV 只提供了读取和存储.xml和.yml 文件格式的函数. 读取.xml文件的C++例程如下: cv::FileStorage fs; //OpenCV 读XML文件流 cv::Mat De ...
- percona监控模板图形解释
http://blog.itpub.net/28916011/viewspace-1971933/ percona监控mysql的几张图形解释 最近,我仔细研究了一下percona监控mysq ...
- MySQL如何选择float, double, decimal
http://yongxiong.leanote.com/post/mysql_float_double_decimal
- string中find函数的使用
9.47 编写程序,首先查找string"ab2c3d7R4E6"中的每个数字字符,然后查找其中每个字母字符.编写两个版本的程序,第一个要使用find_first_of,第二个要使 ...
- 将字符串写进txt中方式
try { File file = new File(filePath); PrintStream ps = new PrintStream(new FileOutputStream(file)); ...
- Enable HTTPS in Spring Boot
Spring-boot-enable-ssl Enable HTTPS in Spring Boot APRIL 14, 2015DRISS AMRI This weekend I answered ...
- gem 'logstash-devutils'
需求 为了开发新的 logstash 插件 问题 原以为只是很简单的 bundle install 就能搞定的事情,实际却遇到了一堆问题. 1. clone git git@github.com:lo ...
- Oracle SQL Developer 操作
.新建 数据库连接 菜单->文件->新建 ->新建数据库连接 ->连接名: 用户名:userA 口 令: 连接类型:基本/.. 角色:默认值/SYSDBA 主机名:localh ...
- Servlet原理
Servlet主要用来处理客户端请求并将其结果发送到客户端,下面我们来详细看一下Servlet. 一.Servlet的生命周期 Servlet的生命周期是由Servlet的容器来控制的(Tomcat ...