用C#写的处理代码,有待改进:
string s = "张三(10),李四(20),王五(30),赵六(40)";
int[] num=new int[20]; //该数组用来存储id号
int i=0,count=0; //count用于统计有多少个id
int index1, index2 = 0;
while (true)
{
index1 = s.IndexOf('(');
index2 = s.IndexOf(')');
num[i] = int.Parse(s.Substring(index1 + 1, index2 - index1 - 1));
count++;
if (index2 + 1 == s.Length)
break;
else
{
s = s.Substring(index2 + 2);
i++;
}
}
for(int j=0;j<i+1;j++)
{
Console.WriteLine(num[j]);
}
Console.WriteLine(count);