62,254
社区成员
发帖
与我相关
我的任务
分享using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text.RegularExpressions;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
计算();
}
void 计算()
{
string strInput = @"53 0
48 1
54 2
48 3
42 4
36 5
35 6
35 7
29 8
29 9
30 10
23 11
23 12
23 13
23 14
23 15
18 16
20 17
18 18
18 19
18 20
17 21
18 22
19 23
14 24
10 25
12 26
13 27
14 28
13 29
13 30
15 31
16 32
8 33
15 34
15 35
8 36
8 37
8 38
8 39
9 40 ";
int sum = 0;
Regex regex = new Regex(@"\r\n");
foreach (var item in regex.Split(strInput))
{
Regex _regex = new Regex(@"\s+");
int i = 0;
foreach (var _item in _regex.Split(item))
{
if (i % 2 != 0)
{
if (_item == "")
{
continue;
}
sum += Convert.ToInt32(_item);
}
i++;
}
}
}
}
int sum = 0;
foreach (int x in col1)
{
sum += x;
}
System.Console.WriteLine(sum);