题目描述:
截止到2014.2.23,亚太互联网络信息中心分配给中国(不含港、澳、台及钓鱼岛)的IPv4地址是多少个?
解题链接: http://ctf1.shiyanbar.com/ppc/delegated-apnic-20140223.gz
直接读取文件,代码:using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography;
using System.IO;
namespace Test
{
class Program
{
static void Main(string[] args)
{
int count = 0;
StreamReader sr = new StreamReader("1.txt");
string s;
while ((s = sr.ReadLine()) != null) {
if (s.IndexOf("ipv4") <= 0) break;
if (s.IndexOf("CN") >= 0)
{
string[] str = s.Split('|');
count += Convert.ToInt32(str[4]);
}
}
Console.WriteLine(count);
Console.ReadLine();
}
}
}
提交330393088,通过!