题目1203:IP地址-----------------把IP地址当成四个数字来输入就简单了很多

#include<stdio.h>
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        while(n--)
        {
            int a,b,c,d;
            scanf("%d.%d.%d.%d",&a,&b,&c,&d);
            if ((a>-1 && a<256)&&(b>-1 && b<256)&&(c>-1 && c<256)&&(d>-1 && d<256))
            printf("Yes!\n");
            else printf("No!\n"); 

        }
    }
    return 0;
}
时间: 2024-08-10 01:55:38

题目1203:IP地址-----------------把IP地址当成四个数字来输入就简单了很多的相关文章

IP地址理解_IP地址=网络地址+主机地址,但是具体前面多少是网络地址看题目说明

题目:   属于网络112.10.200.0/21的地址是() 112.10.206.0 112.10.217.0 112.10.224.0 112.10.198.0 分析解答: 总结: 首先,明白后面那个21是什么意思,21表示这个IP的前21位表示的是网络地址,那剩下的11位表示主机地址.IP地址共32位=4个字节*8位/字节: 其次,就是理解一个点隔开的就是一个字节,那么前面21位到哪了呢. 将200写成二进制=128+64+8=11001000,因此前面21位,截取200的前5位,剩余的

[LeetCode] Restore IP Addresses 复原IP地址

Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example:Given "25525511135", return ["255.255.11.135", "255.255.111.35"]. (Order does not matter) 这道题要求是复原IP地址,IP地

[LeetCode] Validate IP Address 验证IP地址

In this problem, your job to write a function to check whether a input string is a valid IPv4 address or IPv6 address or neither. IPv4 addresses are canonically represented in dot-decimal notation, which consists of four decimal numbers, each ranging

使用新浪IP库获取IP详细地址

<?php class Tool{ /** * 获取IP的归属地( 新浪IP库 ) * * @param $ip String IP地址:112.65.102.16 * @return Array */ static public function getIpCity($ip) { $ip = preg_replace("/\s/","",preg_replace("/\r\n/","",$ip)); $link = &

[LeetCode]46. Restore IP Addresses复原IP地址

Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example: Given "25525511135", return ["255.255.11.135", "255.255.111.35"]. (Order does not matter) Subscribe to se

iphone开发之获取网卡的MAC地址和IP地址

本文转载至 http://blog.csdn.net/arthurchenjs/article/details/6358489 这是获取网卡的硬件地址的代码,如果无法编译通过,记得把下面的这几个头文件加上把. #include <sys/socket.h> // Per msqr#include <sys/sysctl.h>#include <net/if.h>#include <net/if_dl.h> #pragma mark MAC addy// Re

如果重新设计网络,有没有可能合并IP地址跟MAC地址?

前阵子看网络基础相关的书籍,冒过一个疑问,为什么要有MAC地址跟IP地址?两者可否合二为一? 现在的逻辑是这样子:在数据传输过程中,路由器查看这个数据包的IP地址,跟路由表中记录的“IP集合:下一跳的mac地址”做对照,确定了要往那边扔:网卡在接收数据的时候,也会看看这个数据包中记录的目标MAC地址是不是自己,只接收自己的. MAC地址是数据链路层使用到的,IP地址是网络层使用到的.MAC地址是硬件的物理属性,在网卡上固定不变,IP地址是逻辑属性. 所以,因为网络分层的设计,很自然的就想到要使用

php 通过ip获取所在城市地址信息 获取计算机外网ip

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-

IP地址与MAC地址

众所周知,每一块网卡在出厂时都烧录了世界唯一的MAC地址,使用该地址可以在网络中识别不同的计算机.同时,互联网中也使用IP地址来定位客户端,这是因为IP地址比MAC地址定位更方便,而且也更加便于记忆.  1.1 IP地址在大多数的局域网中,IP地址是计算机之间通信的唯一依据.当网络中计算机数量比较多时,想要准确记忆每一台计算机的IP地址,显然是一件不太可能的事情.如果网络规模相当大,而且划分了VLAN,那么网络管理员更无法准确记忆用户IP地址了. IP信息查看--ipconfigipconfig