2 tianlong68jerry tianlong68jerry 于 2017.09.02 20:29 提问

想写一个数组里面五个IP地址,凡事192.168开头就说他们是同一局域网 1C

!!!好难好难:
主要是说,让用户输入5个字符串,是IP地址类似于192.168.50.3
下面是我要实现的OUTPUT:
嗯,使用C语言
Sample run of program should create the following output.

Sample run 1:
Enter 5 IP addresses in separate lines:
192.168.50.1
192.168.50.3
171.20.51.23
171.20.197.51
192.168.52.4
192.168.50.1 and 192.168.50.3 are in the same local network.

Sample run 2:
Enter 5 IP addresses in separate lines:
192.168.50.1
192.168.50.3
171.20.51.23
171.20.197.51
192.168.50.4
192.168.50.1 and 192.168.50.3 are in the same local network.
192.168.50.1 and 192.168.50.4 are in the same local network.
192.168.50.3 and 192.168.50.4 are in the same local network.

3个回答

caozhy
caozhy   Ds   Rxr 2017.09.03 08:45

这个涉及子网掩码才能判断,你说的“192.168开头就说他们是同一局域网”只是子网掩码为255.255.0.0的特例

what951006
what951006   Rxr 2017.09.03 10:15

使用char数组来装入这些IP地址,如果你只是简单的匹配,判断那就是一个比较简单的逻辑。
如果要真正的判读这个IP连不连的通的话。
http://blog.csdn.net/what951006/article/details/73695117

besnow
besnow   2017.09.04 14:48

分割成数组,然后equals前两个值

Csdn user default icon
上传中...
上传图片
插入图片