读入字符串,按'~'进行拆分,如果没有找到'~'则地址非法;拆分成ip和mask后,先对mask进行检查,mask转成一个十进制的数,按位从最右边开始找第一个1,这个1的左边不能出现0;使用sscanf对点分十进制的ip进行拆分,得到a,b,c,d,通过对a、b的判断来对ip地址进行划分。 #include <stdio.h> #include <iostream> #include <string> #include <vector> using namespace std; enum addr_type { A_type, /*A类地址*/ ...