!!!好难好难:
主要是说,让用户输入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.
这个涉及子网掩码才能判断,你说的“192.168开头就说他们是同一局域网”只是子网掩码为255.255.0.0的特例
使用char数组来装入这些IP地址,如果你只是简单的匹配,判断那就是一个比较简单的逻辑。
如果要真正的判读这个IP连不连的通的话。
http://blog.csdn.net/what951006/article/details/73695117
分割成数组,然后equals前两个值