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:

2

7

   2

6

  2

5

  2

4

  2

3

   2

2

  2

1

  2

0


128 64 32 16 8 4 2 1

Input

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
01010000000100000000000000000001

Sample Output

0.0.0.0
3.128.255.255
203.132.229.128
80.16.0.1

Source

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的更多相关文章

  1. poj 2105 IP Address

    IP Address Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 18951   Accepted: 10939 Desc ...

  2. poj 2105 IP Address(水题)

    一.Description Suppose you are reading byte streams from any device, representing IP addresses. Your ...

  3. IP Address 分类: POJ 2015-06-12 19:34 12人阅读 评论(0) 收藏

    IP Address Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 19125   Accepted: 11053 Desc ...

  4. poj2105 IP Address(简单题)

    题目链接:id=2105">http://poj.org/problem?id=2105 ----------------------------------------------- ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. Ubuntu setup Static IP Address

    Change Ubuntu Server from DHCP to a Static IP Address If the Ubuntu Server installer has set your se ...

  9. 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 ...

随机推荐

  1. 去ECSHOP版权,去官方后门

    ECShop是一款B2C独立网店系统,适合企业及个人快速构建个性化网上商店.系统开源但不免费,是基于PHP语言及MYSQL数据库构架开发的跨平台开源程序.目前最新版本为2.7.3 0708版.1.首先 ...

  2. 获利能力分析COPA的BAPI:BAPI_COPAACTUALS_POSTCOSTDATA 通过增强返回凭证号

    用这个BAPI:BAPI_COPAACTUALS_POSTCOSTDATA 记录销售成本的时候,发现不能return生产的co凭证号,利用内存应该是最好的方法. SCN上的帖子:https://blo ...

  3. paip.提升性能---- 网站并发数的总结.txt

    paip.提升性能---- 网站并发数的总结.txt 作者Attilax ,  EMAIL:1466519819@qq.com  来源:attilax的专栏 地址:http://blog.csdn.n ...

  4. innobackupex --slave-info参数的含义和适用场景

    http://blog.itpub.net/28916011/viewspace-1969135/       我有个问题一直没弄明白,就是innobackupex里面的--slave-info这个参 ...

  5. linux僵死进程的产生与避免

      作者:lingdxuyan来源:ChinaUnix技术博客,本文版权由lingdxuyan所有,如需转载,请注明出处. 一个进程在调用exit命令结束自己的生命的时候,其实它并没有真正的被销毁, ...

  6. [原创]如何写好SqlHelper

    所有写数据库应用的都会遇到SqlHelper.每个人实现的也不同,网上现成的例子也很多.但在实际操作中,大部分都不实用.什么样的才是实用的?答:适合应用场景的! 下面来介绍下我写的一个关于Oracle ...

  7. UNIX标准化及实现之选项

    POSIX.1的2001版,包括了ISO C标准所指定的各个函数.其接口分成了两类:必需接口和可选接口.可选接口按功能又进一步分成50个区.表1中按它们各自的选项代码总结了没有被弃用的编程接口.选项代 ...

  8. android中设置快捷键方法setShortcut参数的说明

    setShortcut之所以要两个参数来设定两个快捷键是为了应对不同的手机键盘.数字快捷键为12键键盘(0~9,*,#,共12个按键)所准备的.其实我怀疑有这种键盘的手机能装Android么?因为我的 ...

  9. linux实例 批量修改图片文件名

    1.如10.11一批这样的目录,10.11 10.12等等 然后里面的图片.jpg文件要修改成对应的日期.jpg,也就是说 编程1011.jpg这样的文件名 示例如下: #!/bin/bashfor ...

  10. [转]javascript指定事件处理程序包括三种方式:

    javascript指定事件处理程序包括三种方式: (1):DOM0级事件处理程序 如: 代码如下: var btn=document.getElementById("mybtn" ...