题意:输入m代表接下来的数据个数,计算接下来输入数据的网络掩码,和最小网络地址. 思路:①子网掩码:先将数据转为二进制,判断从哪一位开始有数据不一样,记下下标index,则子网掩码是index的前面是1,后面是0(2#),就是子网掩码,再转为10#输出: ②最小网络地址:用任意一个IP与子网掩码进行按位与运算得出最小IP,与运算的符号为&. import java.util.Scanner; public class UVA1590 { public static void main(Strin…
Description Alex is administrator of IP networks. His clients have a bunch of individual IP addresses and he decided to group all those IP addresses into the smallest possible IP network. Each IP address is a 4-byte number that is written byte-by-b…
Alex is administrator of IP networks. His clients have a bunch of individual IP addresses and he decided to group all those IP addresses into the smallest possible IP network. Each IP address is a 4-byte number that is written byte-by-byte in a dec…
书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 代码:(Accepted,0 ms) //UVa1590 - IP Networks #include<iostream> unsigned i, m, num, ip[4], ipmax[4], ipmin[4], mask[4]; int cmp(unsigned *a, unsigned *b) {//compare for (int i = 0;i < 4;++i) { if (a[i] <…
一.IP 1.地址格式 互联网上每一台计算机都有一个唯一标示自己的标记,这个标记就是IP地址.IP 地址使用32 位长度二进制数据标示,一般在实际中看到的大部分IP地址都是以十进制的数据形式标示的,如:192.168.1.3,IP地址格式如下: IP 地址 = 网络地址 + 主机地址 网络号:用于识别主机所在的网络 主机号:用于识别网络中的主机 2.地址分类 IP地址按照数字区域,分为5类,如下所示: A 类:政府机构 B 类:中等规模的公司 C 类:任何需要的人 D 类:用于组播 E 类:用于…