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 ...
随机推荐
- 实例:ABAP Tree Control 使用与ALV Grid对象关联
Tree Control 是最常用的Windows控件之一,在其他语言中成为"Tree View"等,ABAP的 Tree Contiol 能实现类似的功能. 本文主要介绍一下内容 ...
- Parse error: syntax error, unexpected T_PUBLIC in 问题解决
class 类中 public function _getInfo($sn){ $title = ''; $_array = explode('~', $sn); ...
- iOS开发——面试笔试精华(三)
面试笔试精华(三) 1. When to use NSMutableArray and when to use NSArray? 什么时候使用NSMutableArray,什么时候使用N ...
- unity3D Socket连接C#server出现unity3D编辑器再次启动连接 unity3D编辑器马上卡死
unity3D Socket与C#server第一次连接时通讯正常.客服端段关闭后.unity3D编辑器再次启动连接 unity3D编辑器马上卡死 原因是Socket处于异步状态,而异步线程是不受Un ...
- android116 轮播 viewPager实现
布局: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:to ...
- slave_net_timeout
http://blog.csdn.net/lwei_998/article/details/46864453
- mysqldump 的一些使用参数
备份数据库#mysqldump 数据库名 >数据库备份名 #mysqldump -A -u用户名 -p密码 数据库名>数据库备份名 #mysqldump -d -A --add-drop- ...
- Apache中 RewriteRule 规则参数介绍
Apache中 RewriteRule 规则参数介绍 摘要: Apache模块 mod_rewrite 提供了一个基于正则表达式分析器的重写引擎来实时重写URL请求.它支持每个完整规则可以拥有不限数量 ...
- php面试常用算法
这些都是真实的IT公司招聘PHP程序员的面试题,这些都是简单的基本算法.包括:冒泡算法.快速排序算法.二分查找算法.顺序算法. 冒泡排序,对象可以是一个数组 01 function bubble_so ...
- Github 上的 iOS 开源项目
在 Github 上 Star 太多了,有时候很难找到自己想要的开源库,所以在此记录下来.便于自己开发使用,也顺便分享给大家. 动画 awesome-ios-animation收集了iOS平台下比较主 ...